Вопрос

I have created a safari plugin using NPAPI and I want to add a NSView in my plug-in.

When I try to get NPWindow throw function NPP_SetWindow(NPP instance, NPWindow* window), the second parameter is nil.

I think my plug-in is windowless, but i don't know how to create a windowed.

Это было полезно?

Решение

NPAPI on Mac does not support NSView as a windowing mode. There are two supported modes:

There used to be a QuickDraw mode, but that's deprecated.

For more information, see Stuart Morgan's excellent blog post on the subject.

It is possible to make a NSView render to a CoreGraphics context but you'd have to proxy all of the events and it is far from perfect.

EDIT: To further explain the answer to your question, the reason that the window parameter is NULL (it's a C api, not Obj C, so it's NULL, not nil... despite them being the same thing =]) is because in the Cocoa Event Model you get a CGContextRef as part of the draw event which is only valid during the context of that event.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top