NPAPI:CocoaEventModel: Difference between revisions

m (Add a note explaining that this assumes to CoreGraphics drawing model)
 
(51 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== This Document ==
= Status =


This proposal was submitted by Anders Carlsson of Apple Computer, Inc. and posted to the plugin-futures (@mozilla.org) mailing list. It has been edited and formatted here by Josh Aas of Mozilla Corporation.
Accepted, ready for implementation. Assigned NPAPI version number 23.


== Overview ==
== Contributors ==


We're introducing the concept of the "event model" for Mac plug-ins. This is similar to the already existing concept of drawing models.
* Last modified: January 18, 2011
* Authors: Anders Carlsson (Apple)
* Contributors: Josh Aas (Mozilla Corporation)


== Event Model Negotiation ==
== Overview ==
 
When the plug-in starts, it negotiates the event model with the browser.
 
A plug-in may call NPN_GetValue() with the following NPNVariables to query the browser for its supported event models:
 
#ifndef NP_NO_CARBON
    , NPNVsupportsCarbonBool = 2003 /* TRUE if the browser supports the Carbon event model */
#endif
    , NPNVsupportsCocoaBool = 2004 /* TRUE if the browser supports the Cocoa event model */
 
Once the plug-in finds a supported event model, it calls NPN_SetValue to tell the browser which event model it has. We're adding a new NPNVariable for this:
 
NPPVpluginEventModel = 1001,


The value of the NPPVpluginEventModel is an NPEventModel, a new enumeration we're adding:
The Cocoa event model is an alternative event model for 32-bit Mac OS X plugins and the default event model for 64-bit Mac OS X plugins.


typedef enum {
<i>Note: This specification pre-dates some drawing specifications, so it assumes the CoreGraphics drawing model. Comments related to drawing may not apply to newer drawing models such as [[NPAPI:CoreAnimationDrawingModel|Core Animation]] and [[NPAPI:InvalidatingCoreAnimation|invalidating Core Animation]].</i>
#ifndef NP_NO_CARBON
    NPEventModelCarbon = 0,
#endif
    NPEventModelCocoa = 1,
  } NPEventModel;


== The Carbon event model ==
== Event model negotiation ==


The Carbon event model is the event model used by all plug-ins today. If a plug-in does not negotiate an event model, the Carbon event model is used.
For documentation on negotiating event models, see [[NPAPI:Models]]. The event model variables for Cocoa are:


In 64-bit, the Carbon event model does not exist, and the Cocoa event model is used if the plug-in does not negotiate an event model.
* NPEventModelCocoa (NPEventModel = 1)
* NPNVsupportsCocoaBool (NPNVariable = 3001)


== The Cocoa event model ==
== The Cocoa event model ==
Line 43: Line 28:
* NPP_HandleEvent now passes an NPCocoaEvent struct.
* NPP_HandleEvent now passes an NPCocoaEvent struct.
* Null events are no longer sent.
* Null events are no longer sent.
* The window handle in NP_CGContext and NP_GLContext is now an NSWindow* instead of a WindowRef.
* The window field of NPWindow is null. The CGContextRef to use when drawing is a member of the draw event struct.
 
All coordinates passed to the plugin via the Cocoa event model are based on the origin being in the top-left (not bottom-left as in standard Cocoa coordinates). This is on account of the fact that the CoreGraphics context given to the plugins is flipped for historical reasons.


The Cocoa event model can not be used with the QuickDraw drawing model.
The Cocoa event model can not be used with the QuickDraw drawing model.
Line 53: Line 40:
  typedef struct _NPCocoaEvent {
  typedef struct _NPCocoaEvent {
     NPCocoaEventType type;
     NPCocoaEventType type;
    uint32 version;
     union {
     union {
         struct {
         struct {
Line 69: Line 57:
             NPNSString *charactersIgnoringModifiers;
             NPNSString *charactersIgnoringModifiers;
             NPBool isARepeat;
             NPBool isARepeat;
            uint16 keyCode;
            uint16 keyCode;
         } key;
         } key;
         struct {
         struct {
    double x, y, width, height;
            CGContextRef context;
            double x;
            double y;
            double width;
            double height;
         } draw;
         } draw;
         struct {
         struct {
             NPBool hasFocus;
             NPBool hasFocus;
         } focus;      
         } focus;
     } event;
        struct {
            NPNSString *text;
        } text;
     } data;
  } NPCocoaEvent;
  } NPCocoaEvent;


NPCocoaEventType is one of the following:
NPCocoaEventType is one of the following:


typedef enum {
typedef enum {
    NPCocoaEventDrawRect
    NPCocoaEventDrawRect = 1,
    NPCocoaEventMouseDown,
    NPCocoaEventMouseDown,
    NPCocoaEventMouseUp,
    NPCocoaEventMouseUp,
    NPCocoaEventMouseMoved,
    NPCocoaEventMouseMoved,
    NPCocoaEventMouseEntered,
    NPCocoaEventMouseEntered,
    NPCocoaEventMouseExited,
    NPCocoaEventMouseExited,
    NPCocoaEventMouseDragged,
    NPCocoaEventMouseDragged,
    NPCocoaEventScrollWheel,
    NPCocoaEventKeyDown,
    NPCocoaEventKeyDown,
    NPCocoaEventKeyUp,
    NPCocoaEventKeyUp,
    NPCocoaEventFlagsChanged,
    NPCocoaEventFlagsChanged,
    NPCocoaEventFocusChanged,
    NPCocoaEventFocusChanged,
    NPCocoaEventWindowFocusChanged,
    NPCocoaEventWindowFocusChanged,
    NPCocoaEventScrollWheel,
} NPCocoaEventType;
    NPCocoaEventTextInput
} NPCocoaEventType;
 
version is a per event version number. It is currently 0 for all events.


== General event struct members ==
== General event struct members ==


uint32 modifierFlags;
uint32 modifierFlags;
 
An integer bit field indicating the modifier keys. It uses the same constants as -[NSEvent modifierFlags].
An integer bit field indicating the modifier keys. It uses the same constants as -[NSEvent modifierFlags].


== Mouse events ==
== Mouse events ==


NPCocoaEventMouseDown - Fired when a mouse button is pressed
* NPCocoaEventMouseDown - Fired when a mouse button is pressed
NPCocoaEventMouseUp - Fired when a mouse button is released
* NPCocoaEventMouseUp - Fired when a mouse button is released
NPCocoaEventMouseMoved - Fired when the mouse is moved
* NPCocoaEventMouseMoved - Fired when the mouse is moved
NPCocoaEventMouseEntered - Fired when the mouse enters the plug-in area.
* NPCocoaEventMouseEntered - Fired when the mouse enters the plug-in area.
NPCocoaEventMouseExited - Fired when the mouse exits the plug-in area.
* NPCocoaEventMouseExited - Fired when the mouse exits the plug-in area.
NPCocoaEventMouseDragged - Fired when the mouse is moved with a mouse button pressed. This will fire even if the mouse is moved outside of the plug-in area.
* NPCocoaEventMouseDragged - Fired when the mouse is moved with a mouse button pressed. This will fire even if the mouse is moved outside of the plug-in area.
NPCocoaEventScrollWheel - Fired when the mouse's scroll wheel has moved.
* NPCocoaEventScrollWheel - Fired when the mouse's scroll wheel has moved.
 
double pluginX;


double pluginX;
The X position of the mouse cursor, in the plug-in's coordinate system.
The X position of the mouse cursor, in the plug-in's coordinate system.


double pluginY;
double pluginY;
 
The Y position of the mouse cursor, in the plug-in's coordinate system.
The Y position of the mouse cursor, in the plug-in's coordinate system.


int32 buttonNumber;
int32 buttonNumber;
 
The button number of the mouse button that generated the mouse event.
The button number of the mouse button that generated the mouse event.


int32 clickCount;
int32 clickCount;
 
The number of mouse clicks associated with the event.
The number of mouse clicks associated with the event.


double deltaX;
double deltaX;
double deltaY;
double deltaY;
double deltaZ;
double deltaZ;
 
The X, Y or Z coordinate change for a scroll wheel, mouse-move, or mouse-drag event.
The X, Y or Z coordinate change for a scroll wheel, mouse-move, or mouse-drag event.


Line 134: Line 138:
Keyboard events will only be fired when the plug-in has keyboard focus.
Keyboard events will only be fired when the plug-in has keyboard focus.


NPCocoaEventKeyDown - Fired when a key is pressed
* NPCocoaEventKeyDown - Fired when a key is pressed
NPCocoaEventKeyUp - Fired when a key is released
* NPCocoaEventKeyUp - Fired when a key is released
NPCocoaEventFlagsChanged - Fired when a modifier key is pressed or released
* NPCocoaEventFlagsChanged - Fired when a modifier key is pressed or released
 
NPNSString *characters;


NPNSString *characters;
The characters associated with the key-up or key-down event. Will always be null for NPCocoaEventFlagsChanged.
The characters associated with the key-up or key-down event. Will always be null for NPCocoaEventFlagsChanged.


NPNSString *charactersIgnoringModifiers;
NPNSString *charactersIgnoringModifiers;
 
The characters generated by the receiving key event as if no modifier key (except for Shift) applies. Will always be null for NPCocoaEventFlagsChanged.
The characters generated by the receiving key event as if no modifier key (except for Shift) applies. Will always be null for NPCocoaEventFlagsChanged.


NPBool isARepeat;
NPBool isARepeat;
 
TRUE if the key event is a repeat caused by the user holding the key down, FALSE if the key event is new. Will always be FALSE for NPCocoaEventFlagsChanged.
TRUE if the key event is a repeat caused by the user holding the key down, FALSE if the key event is new. Will always be FALSE for NPCocoaEventFlagsChanged.


uint16 keyCode;
uint16 keyCode;
 
The virtual key code for the keyboard key associated with the key event.
The virtual key code for the keyboard key associated with the key event.


== Focus events ==
== Focus events ==


NPCocoaEventFocusChanged - Fired when the plug-in gains or loses focus.
* NPCocoaEventFocusChanged - Fired when the plug-in gains or loses focus.
NPCocoaEventWindowFocusChanged - Fired when the plug-in window gains or loses focus.
* NPCocoaEventWindowFocusChanged - Fired when the plug-in window gains or loses focus.
 
NPBool hasFocus;


NPBool hasFocus;
TRUE if the plug-in or window now has focus, FALSE otherwise.
TRUE if the plug-in or window now has focus, FALSE otherwise.


== Draw event ==
== Draw event ==


NPCocoaEventDrawRect - Fired whenever the plug-in should draw.
* NPCocoaEventDrawRect - Fired whenever the plug-in should draw.
 
CGRect rect;


CGRect rect;
The dirty rect in plug-in coordinates.
The dirty rect in plug-in coordinates.


Line 169: Line 179:
When the Cocoa drawing model, null events are no longer used. Instead, two new timer functions have been added:
When the Cocoa drawing model, null events are no longer used. Instead, two new timer functions have been added:


uint32 NPN_ScheduleTimer(NPP npp, uint32 interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32 timerID));
uint32 NPN_ScheduleTimer(NPP npp, uint32 interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32 timerID));


npp - The plug-in instance pointer.
* npp - The plug-in instance pointer.
interval - The timer interval in milliseconds.
* interval - The timer interval in milliseconds.
repeat - Whether the timer should reschedule itself automatically.
* repeat - Whether the timer should reschedule itself automatically.
timerFunc - A pointer to the function that will be run when the timer fires.
* timerFunc - A pointer to the function that will be run when the timer fires.


This schedules a timer. The return value is 0 on error or a unique timeout ID on success.
This schedules a timer. The return value is 0 on error or a unique timeout ID on success.


void NPN_UnscheduleTimer(NPP npp, uint32 timerID)
void NPN_UnscheduleTimer(NPP npp, uint32 timerID)


npp - The plug-in instance pointer.
* npp - The plug-in instance pointer.
timerID - A timerID returned from NPN_ScheduleTimer.
* timerID - A timerID returned from NPN_ScheduleTimer.


This unschedules a previously scheduled timer.
This unschedules a previously scheduled timer.
Line 191: Line 201:
To pop up a context menu, the following function should be used
To pop up a context menu, the following function should be used


NPError NPN_PopUpContextMenu(NPP npp, NPNSMenu *menu)
NPError NPN_PopUpContextMenu(NPP npp, NPNSMenu *menu)


Note that this must be called from the NPP_HandleEvent callback, and will return an error otherwise.
Note that this must be called from the NPP_HandleEvent callback, and will return an error otherwise. The top left corner of the menu will be positioned at the location corresponding to the current event being handled.


The NPNSMenu is a typedef to NSMenu.
The NPNSMenu is a typedef to NSMenu.


== Your feedback is important! ==
== Text Input ==
 
(Note: Due to an [[NPAPI:CocoaCompositionClarification|amended specification]] and inconsistency in original implementations the variable <code>NPNVsupportsUpdatedCocoaTextInputBool</code> (NPNVariable = 3002) will indicate whether a browser supports this updated specification or not. If this is undefined or is false then text input behavior will vary between browsers.)
 
Plugin-ins can return 2, (<code>kNPEventStartIME</code>) from <code>NPP_HandleEvent</code> for <code>NPCocoaEventKeyDown</code> events when they want the browser to have an input method process the event.
 
The input method may open an out-of-line input window where complex text can be composed. When the user confirms the text and dismisses the window, an <code>NPCocoaEventTextInput</code> event is sent with the relevant unicode string.
 
Composition is considered to have started once a plugin returns <code>kNPEventStartIME</code> for a <code>NPCocoaEventKeyDown</code> event. Once a composition is started, plugins will not receive <code>NPCocoaEventKeyDown</code> or <code>NPCocoaEventKeyUp</code> events associated with compositions regardless of whether the composition results in a <code>NPCocoaEventTextInput</code> event or not (it may be canceled or the key press may not result in a meaningful composition).
 
<code>NPCocoaEventFlagsChanged</code> events will be sent at all times, even during composition.
 
* Example 1
** User presses the "a" key in an en-us context.
** Plugin gets a <code>NPCocoaEventKeyDown</code> event and returns <code>kNPEventStartIME</code>.
** Plugin gets <code>NPCocoaEventTextInput</code> event for string "a".
** Plugin does not get <code>NPCocoaEventKeyUp</code> event for "a" key.
 
* Example 2
** User presses "enter" in an out-of-line composition window to commit a complex text composition that started with the plugin returning <code>kNPEventStartIME</code> for a <code>NPCocoaEventKeyDown</code> event.
** Plugin does not receive an <code>NPCocoaEventKeyDown</code> event for the "enter" key. It is considered to belong to the composition.
** Plugin receives <code>NPCocoaEventTextInput</code> event containing composed string.
** Plugin does not receive a <code>NPCocoaEventKeyUp</code> event for the "enter" key. It is considered to belong to the composition.
 
* Example 3
** User presses "option-e" in an en-us context.
** Plugin receives a <code>NPCocoaEventKeyDown</code> event for "option-e" and returns <code>kNPEventStartIME</code>.
** Plugin does not receive a <code>NPCocoaEventKeyUp</code> event for the "option-e" key. It is considered to belong to the composition.
** User presses "e" to complete a composition of the string "é".
** Plugin does not receive a <code>NPCocoaEventKeyDown</code> event for the "e" key. It is considered to belong to the composition.
** Plugin receives <code>NPCocoaEventTextInput</code> event containing composed string "é".
** Plugin does not receive a <code>NPCocoaEventKeyUp</code> event for the "e" key. It is considered to belong to the composition.


If you are at all involved in Mac browser or plugin development, these changes will affect you. So make your voice heard!  We're open to any questions or comments you might have about these proposed changes. Please post comments on the plugin-futures (@mozilla.org) mailing list.
* Example 4
** User presses "F3" key in an en-us context.
** Plugin receives a <code>NPCocoaEventKeyDown</code> event for the "F3" key and returns <code>kNPEventStartIME</code>.
** Plugin does not receive a <code>NPCocoaEventTextInput</code> event because F3 is a dead key as far as composition is concerned. Composition is considered to be canceled.
** Plugin does not receive a <code>NPCocoaEventKeyUp</code> event for the "F3" key. It is considered to belong to the composition which is now canceled.


== Notes ==
== Notes ==


* Josh Aas
* Josh Aas
** We need a solution for IME
** Do we need events for multi-touch?

Latest revision as of 07:17, 9 March 2011

Status

Accepted, ready for implementation. Assigned NPAPI version number 23.

Contributors

  • Last modified: January 18, 2011
  • Authors: Anders Carlsson (Apple)
  • Contributors: Josh Aas (Mozilla Corporation)

Overview

The Cocoa event model is an alternative event model for 32-bit Mac OS X plugins and the default event model for 64-bit Mac OS X plugins.

Note: This specification pre-dates some drawing specifications, so it assumes the CoreGraphics drawing model. Comments related to drawing may not apply to newer drawing models such as Core Animation and invalidating Core Animation.

Event model negotiation

For documentation on negotiating event models, see NPAPI:Models. The event model variables for Cocoa are:

  • NPEventModelCocoa (NPEventModel = 1)
  • NPNVsupportsCocoaBool (NPNVariable = 3001)

The Cocoa event model

If a plug-in sets the event model to NPEventModelCocoa, then the following changes are made, each of which is described in detail further in this document:

  • NPP_HandleEvent now passes an NPCocoaEvent struct.
  • Null events are no longer sent.
  • The window field of NPWindow is null. The CGContextRef to use when drawing is a member of the draw event struct.

All coordinates passed to the plugin via the Cocoa event model are based on the origin being in the top-left (not bottom-left as in standard Cocoa coordinates). This is on account of the fact that the CoreGraphics context given to the plugins is flipped for historical reasons.

The Cocoa event model can not be used with the QuickDraw drawing model.

NPP_HandleEvent

In the Cocoa event model, NPP_HandleEvent now passes a new struct, NPCocoaEvent, which is shown below:

typedef struct _NPCocoaEvent {
    NPCocoaEventType type;
    uint32 version;
    union {
        struct {
            uint32 modifierFlags;
            double pluginX;
            double pluginY;            
            int32 buttonNumber;
            int32 clickCount;
            double deltaX;
            double deltaY;
            double deltaZ;
        } mouse;
        struct {
            uint32 modifierFlags;
            NPNSString *characters;
            NPNSString *charactersIgnoringModifiers;
            NPBool isARepeat;
            uint16 keyCode;
        } key;
        struct {
           CGContextRef context;
           double x;
           double y;
           double width;
           double height;
        } draw;
        struct {
            NPBool hasFocus;
        } focus;
        struct {
            NPNSString *text;
        } text;
    } data;
} NPCocoaEvent;

NPCocoaEventType is one of the following:

typedef enum {
    NPCocoaEventDrawRect = 1,
    NPCocoaEventMouseDown,
    NPCocoaEventMouseUp,
    NPCocoaEventMouseMoved,
    NPCocoaEventMouseEntered,
    NPCocoaEventMouseExited,
    NPCocoaEventMouseDragged,
    NPCocoaEventKeyDown,
    NPCocoaEventKeyUp,
    NPCocoaEventFlagsChanged,
    NPCocoaEventFocusChanged,
    NPCocoaEventWindowFocusChanged,
    NPCocoaEventScrollWheel,
    NPCocoaEventTextInput
} NPCocoaEventType;

version is a per event version number. It is currently 0 for all events.

General event struct members

uint32 modifierFlags;

An integer bit field indicating the modifier keys. It uses the same constants as -[NSEvent modifierFlags].

Mouse events

  • NPCocoaEventMouseDown - Fired when a mouse button is pressed
  • NPCocoaEventMouseUp - Fired when a mouse button is released
  • NPCocoaEventMouseMoved - Fired when the mouse is moved
  • NPCocoaEventMouseEntered - Fired when the mouse enters the plug-in area.
  • NPCocoaEventMouseExited - Fired when the mouse exits the plug-in area.
  • NPCocoaEventMouseDragged - Fired when the mouse is moved with a mouse button pressed. This will fire even if the mouse is moved outside of the plug-in area.
  • NPCocoaEventScrollWheel - Fired when the mouse's scroll wheel has moved.
double pluginX;

The X position of the mouse cursor, in the plug-in's coordinate system.

double pluginY;

The Y position of the mouse cursor, in the plug-in's coordinate system.

int32 buttonNumber;

The button number of the mouse button that generated the mouse event.

int32 clickCount;

The number of mouse clicks associated with the event.

double deltaX;
double deltaY;
double deltaZ;

The X, Y or Z coordinate change for a scroll wheel, mouse-move, or mouse-drag event.

Keyboard events

Keyboard events will only be fired when the plug-in has keyboard focus.

  • NPCocoaEventKeyDown - Fired when a key is pressed
  • NPCocoaEventKeyUp - Fired when a key is released
  • NPCocoaEventFlagsChanged - Fired when a modifier key is pressed or released
NPNSString *characters;

The characters associated with the key-up or key-down event. Will always be null for NPCocoaEventFlagsChanged.

NPNSString *charactersIgnoringModifiers;

The characters generated by the receiving key event as if no modifier key (except for Shift) applies. Will always be null for NPCocoaEventFlagsChanged.

NPBool isARepeat;

TRUE if the key event is a repeat caused by the user holding the key down, FALSE if the key event is new. Will always be FALSE for NPCocoaEventFlagsChanged.

uint16 keyCode;

The virtual key code for the keyboard key associated with the key event.

Focus events

  • NPCocoaEventFocusChanged - Fired when the plug-in gains or loses focus.
  • NPCocoaEventWindowFocusChanged - Fired when the plug-in window gains or loses focus.
NPBool hasFocus;

TRUE if the plug-in or window now has focus, FALSE otherwise.

Draw event

  • NPCocoaEventDrawRect - Fired whenever the plug-in should draw.
CGRect rect;

The dirty rect in plug-in coordinates.

Null events

When the Cocoa drawing model, null events are no longer used. Instead, two new timer functions have been added:

uint32 NPN_ScheduleTimer(NPP npp, uint32 interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32 timerID));
  • npp - The plug-in instance pointer.
  • interval - The timer interval in milliseconds.
  • repeat - Whether the timer should reschedule itself automatically.
  • timerFunc - A pointer to the function that will be run when the timer fires.

This schedules a timer. The return value is 0 on error or a unique timeout ID on success.

void NPN_UnscheduleTimer(NPP npp, uint32 timerID)
  • npp - The plug-in instance pointer.
  • timerID - A timerID returned from NPN_ScheduleTimer.

This unschedules a previously scheduled timer.

Note that the browser may increase the timeout intervals, for example when the browser window containing the plug-in is minimized.

Popup menus

To pop up a context menu, the following function should be used

NPError NPN_PopUpContextMenu(NPP npp, NPNSMenu *menu)

Note that this must be called from the NPP_HandleEvent callback, and will return an error otherwise. The top left corner of the menu will be positioned at the location corresponding to the current event being handled.

The NPNSMenu is a typedef to NSMenu.

Text Input

(Note: Due to an amended specification and inconsistency in original implementations the variable NPNVsupportsUpdatedCocoaTextInputBool (NPNVariable = 3002) will indicate whether a browser supports this updated specification or not. If this is undefined or is false then text input behavior will vary between browsers.)

Plugin-ins can return 2, (kNPEventStartIME) from NPP_HandleEvent for NPCocoaEventKeyDown events when they want the browser to have an input method process the event.

The input method may open an out-of-line input window where complex text can be composed. When the user confirms the text and dismisses the window, an NPCocoaEventTextInput event is sent with the relevant unicode string.

Composition is considered to have started once a plugin returns kNPEventStartIME for a NPCocoaEventKeyDown event. Once a composition is started, plugins will not receive NPCocoaEventKeyDown or NPCocoaEventKeyUp events associated with compositions regardless of whether the composition results in a NPCocoaEventTextInput event or not (it may be canceled or the key press may not result in a meaningful composition).

NPCocoaEventFlagsChanged events will be sent at all times, even during composition.

  • Example 1
    • User presses the "a" key in an en-us context.
    • Plugin gets a NPCocoaEventKeyDown event and returns kNPEventStartIME.
    • Plugin gets NPCocoaEventTextInput event for string "a".
    • Plugin does not get NPCocoaEventKeyUp event for "a" key.
  • Example 2
    • User presses "enter" in an out-of-line composition window to commit a complex text composition that started with the plugin returning kNPEventStartIME for a NPCocoaEventKeyDown event.
    • Plugin does not receive an NPCocoaEventKeyDown event for the "enter" key. It is considered to belong to the composition.
    • Plugin receives NPCocoaEventTextInput event containing composed string.
    • Plugin does not receive a NPCocoaEventKeyUp event for the "enter" key. It is considered to belong to the composition.
  • Example 3
    • User presses "option-e" in an en-us context.
    • Plugin receives a NPCocoaEventKeyDown event for "option-e" and returns kNPEventStartIME.
    • Plugin does not receive a NPCocoaEventKeyUp event for the "option-e" key. It is considered to belong to the composition.
    • User presses "e" to complete a composition of the string "é".
    • Plugin does not receive a NPCocoaEventKeyDown event for the "e" key. It is considered to belong to the composition.
    • Plugin receives NPCocoaEventTextInput event containing composed string "é".
    • Plugin does not receive a NPCocoaEventKeyUp event for the "e" key. It is considered to belong to the composition.
  • Example 4
    • User presses "F3" key in an en-us context.
    • Plugin receives a NPCocoaEventKeyDown event for the "F3" key and returns kNPEventStartIME.
    • Plugin does not receive a NPCocoaEventTextInput event because F3 is a dead key as far as composition is concerned. Composition is considered to be canceled.
    • Plugin does not receive a NPCocoaEventKeyUp event for the "F3" key. It is considered to belong to the composition which is now canceled.

Notes

  • Josh Aas
    • Do we need events for multi-touch?