I've followed the NetscapeCocoaPlugin example from the nightly Webkit build, and I'm able to build a NPAPI style plugin that uses the Cocoa Event Model.
My question now, is how I can get the NSView inside NPP_SetWindow.
A poster in this thread, says that it's possible using [NSView focusView], but I haven't been able to get this to work
My current function looks like this:
NPError NPP_SetWindow(NPP instance, NPWindow* window)
{
PluginObject *obj = instance->pdata;
obj->window = *window;
NSLog(@"Set Window called");
NSView* currentView = [NSView focusView];
[[NSColor redColor] set]; // Sets current drawing color.
NSRectFill(NSMakeRect(10, 10, 2, 20)); // Defines a rectangle and then fills it with the current drawing color.
[[NSColor colorWithCalibratedRed:0.7 green:0.9 blue:0.3 alpha:1.0] set]; // Sets a new color.
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(5, 0, 10, 10)] fill]; // Draws a circle in the new color.
[currentView setNeedsDisplay:YES];
return NPERR_NO_ERROR;
}