I got into a trouble, because my plug-in want to open file dialog when using command+o,but the safari holded on this event.Anyone has a solution?
2 Answers
I strongly suspect there is nothing you can do about this; as a plugin you are a second class citizen, a guest in the process.

- 14,229
- 4
- 34
- 73
-
Really?I thought my plugin can receive all events when it has focus.But according to what you have said,i should change another shortcut key.it's so the tragedy! – Magical Oct 26 '12 at 01:48
-
Your plugin on mac doesn't actually have a window, so it doesn't ever get focus as far as the OS is concerned. All events come from the browser which forwards the events it thinks are relevant. – taxilian Oct 26 '12 at 05:07
You can accept the command event, you have to listen to set a callback for the event member of NPPluginFuncs struct in NP_GetEntryPoints method.
In that method you'll receive all mouse and keyboard events, as well as window focus events. You can cast the second argument from void* to NPCocoaEvent where you will find all necessary parameters suchs as event type, mouse state, keys and focus data.
Please check which event type you're handling before digging into the 'data' union of NPCocoaEvent, otherwise you can get an EXC_BAD_ACCESS.
I'm having trouble with sharing commands with the browser, in my case Command+O should fire the plugin's file open dialog only, but it's also firing the browser open file dialog. Supposedly, returning TRUE for event handling method should report the browser that the plugin handled the event, but I'm having no luck yet.

- 157
- 1
- 9