NPAPI:CocoaCompositionClarification: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:
= Contributors =
= Contributors =


* Last modified: November 16, 2010
* Last modified: November 28, 2010
* Authors: Josh Aas (Mozilla)
* Authors: Josh Aas (Mozilla)
* Contributors: Stuart Morgan (Google)
* Contributors: Stuart Morgan (Google)
Line 11: Line 11:
= Overview =
= Overview =


This proposal modifies the existing Cocoa NPAPI specification ([[NPAPI:CocoaEventModel]]). After a plugin returns "kNPEventStartIME" for a "NPCocoaEventKeyDown" event the plugin has no way of knowing that it should start handling key events again if IME input is canceled by the browser and no "NPCocoaEventTextInput" is sent.
This proposal modifies the existing Cocoa NPAPI specification ([[NPAPI:CocoaEventModel]]). Plugins need a way to know when complex text composition (started by returning 'kNPEventStartIME' for an 'NPCocoaEventKeyDown' event) has been canceled by the user or the browser. Plugins receive key events during composition and without this extension they cannot tell in-composition key events from post-composition key events unless a composition completes and results in an 'NPCocoaEventTextInput' event.


= Specification Change =
= Specification Change =


In order to provide the plugin with information about whether or not there is a complex text composition in progress we will bump the 'NPCocoaEvent' version to '2'. If a plugin receives an 'NPCocoaEvent' with a version of '2' or higher then the key structure will contain a field of type 'NPBool' called 'compositionInProgress'. This will be set to false when no composition is in progress and true when a composition is in progress.
In order to provide the plugin with information about whether or not there is a complex text composition in progress we will bump the 'NPCocoaEvent' version to '2'. If a plugin receives an 'NPCocoaEvent' with a version of '2' or higher then the key structure will contain a field of type 'NPBool' called 'compositionInProgress'. The 'compositionInProgress' field is only valid for 'NPCocoaEventKeyDown' events and will be set to false when no composition is in progress and true when a composition is in progress.


When 'compositionInProgress' there is not necessarily an input method window open. For example, consider the last key press for a composition which is typically the "enter" key. The sequence of events resulting from that physical key press might be:
= Open Questions =


<ol>
<ul>
<li> Input method window closes.</li>
<li> Alternatively, we could say that once composition is started it will always result in an 'NPCocoaEventTextInput' event and canceled compositions will simply result in an 'NPCocoaEventTextInput' event with an empty string.
<li> Plugin receives 'NPCocoaEventKeyDown' event for enter key with 'compositionInProgress' set to true.</li>
</ul>
<li> Plugin receives 'NPCocoaEventTextInput' for completed composition.</li>
<li> Plugin receives 'NPCocoaEventKeyUp' event for enter key with 'compositionInProgress' set to false.</li>
</ol>
 
Another situation might be one in which returning "kNPEventStartIME" for a 'NPCocoaEventKeyDown' event does not open an input method window. In this case the sequence of events would look like:
 
<ol>
<li> Plugin receives 'NPCocoaEventKeyDown' event for 'g' key with 'compositionInProgress' set to true.</li>
<li> Plugin receives 'NPCocoaEventTextInput' for completed composition, the string "g".</li>
</ol>

Revision as of 09:31, 28 November 2010

Status

Under consideration.

Contributors

  • Last modified: November 28, 2010
  • Authors: Josh Aas (Mozilla)
  • Contributors: Stuart Morgan (Google)

Overview

This proposal modifies the existing Cocoa NPAPI specification (NPAPI:CocoaEventModel). Plugins need a way to know when complex text composition (started by returning 'kNPEventStartIME' for an 'NPCocoaEventKeyDown' event) has been canceled by the user or the browser. Plugins receive key events during composition and without this extension they cannot tell in-composition key events from post-composition key events unless a composition completes and results in an 'NPCocoaEventTextInput' event.

Specification Change

In order to provide the plugin with information about whether or not there is a complex text composition in progress we will bump the 'NPCocoaEvent' version to '2'. If a plugin receives an 'NPCocoaEvent' with a version of '2' or higher then the key structure will contain a field of type 'NPBool' called 'compositionInProgress'. The 'compositionInProgress' field is only valid for 'NPCocoaEventKeyDown' events and will be set to false when no composition is in progress and true when a composition is in progress.

Open Questions

  • Alternatively, we could say that once composition is started it will always result in an 'NPCocoaEventTextInput' event and canceled compositions will simply result in an 'NPCocoaEventTextInput' event with an empty string.