24
edits
No edit summary |
|||
| Line 214: | Line 214: | ||
The NPNSMenu is a typedef to NSMenu. | The NPNSMenu is a typedef to NSMenu. | ||
== Text Input == | |||
In order to interact with the text input management system, we are adding new Mac specific functions: | |||
typedef struct _NPPluginTextInputFuncs { | |||
uint16 size; | |||
uint16 version; | |||
NPP_InsertTextFunc insertText; | |||
NPP_DoCommandBySelectorFunc doCommandBySelector; | |||
NPP_SetMarkedTextFunc setMarkedText; | |||
NPP_UnmarkTextFunc unmarkText; | |||
NPP_HasMarkedTextFunc hasMarkedText; | |||
NPP_AttributedSubstringFromRangeFunc attributedSubstringFromRange; | |||
NPP_MarkedRangeFunc markedRange; | |||
NPP_SelectedRangeFunc selectedRange; | |||
NPP_FirstRectForCharacterRangeFunc firstRectForCharacterRange; | |||
NPP_CharacterIndexForPointFunc characterIndexForPoint; | |||
NPP_ValidAttributesForMarkedTextFunc validAttributesForMarkedText; | |||
} NPPluginTextInputFuncs | |||
which a plug-in implements. | |||
This corresponds to the Cocoa NSTextInput protocol. The documentation for NSTextInput applies to NPPluginTextInputFuncs with one exception. points and rects are given in the plug-in coordinate system, not the screen coordinate system. | |||
We are also adding | |||
typedef struct _NPBrowserTextInputFuncs { | |||
uint16 size; | |||
uint16 version; | |||
NPN_MarkedTextAbandonedFunc markedTextAbandoned; | |||
NPN_MarkedTextSelectionChangedFunc markedTextSelectionChanged; | |||
} NPBrowserTextInputFuncs; | |||
which the browser implements. These two methods correspond to the same NSInputManager[2] methods. | |||
In order to not pollute NPPluginFuncs and NPBrowserFuncs with these methods we are adding a new NPPVariable | |||
/* The plug-in text input vtable */ | |||
NPPVpluginTextInputFuncs = 1002, | |||
which the browser will use to query the plug-in for a pointer to the text input vtable, and | |||
, NPNVbrowserTextInputFuncs = 1002 /* The browser text input vtable */ | |||
which the plug-in can use to query the browser for a pointer to its text input vtable. | |||
==== Handling text input ==== | |||
For a plug-in to handle text input, it must return a pointer to a valid NPPluginTextInputFuncs struct from its NPP_GetValue implementation. | |||
When it wants a key event to be passed to the input method, it must return 0 from NPP_HandleEvent when the event is NPCocoaEventKeyDown. This indicates to the browser that the input manager should handle the event. | |||
== Notes == | == Notes == | ||
* Josh Aas | * Josh Aas | ||
** Do we need events for multi-touch? | ** Do we need events for multi-touch? | ||
edits