Confirmed users
58
edits
m (detailed description of setComposition and endComposition) |
|||
Line 370: | Line 370: | ||
* send a character with its key events. | * send a character with its key events. | ||
* @param modifiers see http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl#206 | * @param modifiers see http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl#206 | ||
* @return true if succeeds. Otherwise false if the input context becomes | * @return true if succeeds. Otherwise false if the input context becomes invalid. | ||
* Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object. | * Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object. | ||
*/ | */ | ||
Promise<boolean> sendKey(long keyCode, long charCode, long modifiers); | Promise<boolean> sendKey(long keyCode, long charCode, [optional] long modifiers); | ||
/* | /* | ||
* Set current | * Set current composing text. This method will start composition or update composition if it | ||
* @param cursor | * has started. The composition will be started right before the cursor position and any | ||
* selected text will be replaced by the composing text. When the composition is started, | |||
* calling this method can update the text and move cursor winthin the range of the composing | |||
* text. | |||
* @param text The new composition text to show. | |||
* @param cursor The new cursor position relative to the start of the composition text. The cursor should | |||
* be positioned within the composition text. This means the value should be >= 0 and <= the length of | |||
* composition text. Defaults to the lenght of composition text, i.e., the cursor will be positioned after | |||
* the composition text. | |||
* | * | ||
* The | * The composing text, which is shown with underlined style to distinguish from the existing text, is used | ||
* | * to compose non-ASCII characters from keystrokes, e.g. Pinyin or Hiragana. The composing text is the | ||
* | * intermediate text to help input complex character and is not committed to current input field. Therefore | ||
* | * if any text operation other than composition is performed, the composition will be automatically | ||
* canceled and the composing text will be cleared. Same apply when the inputContext is lost during a | |||
* unfinished composition session. | |||
* | |||
* To finish composition and commit text to current input field, an IME should call |endComposition|. | |||
*/ | */ | ||
// [JS] A more detailed description of how to use these two functions would be great. | <strike>// [JS] A more detailed description of how to use these two functions would be great. | ||
// It's not really obvious to me what either of these two arguments do. | // It's not really obvious to me what either of these two arguments do.</strike> | ||
Promise<boolean> setComposition(DOMString text, long cursor); | Promise<boolean> setComposition(DOMString text, [optional] long cursor); | ||
/* | /* | ||
* End composition and | * End composition, clear the composing text and commit given text to current input field. The text will | ||
* be committed before the cursor position. | |||
* | * @param text The text to commited before cursor position. If empty string is given, no text will be | ||
* | * committed. | ||
* | |||
* | * | ||
* | * Note that composition always ends automatically with nothing to commit if the composition does not | ||
* explicitly end by calling |endComposition|, but is interrupted by |sendKey|, |setSelectionRange|, | |||
* |replaceSurroundingText|, |deleteSurroundingText|, user moving the cursor, or changing the focus, etc. | |||
*/ | */ | ||
Promise<boolean> endComposition(DOMString text); | Promise<boolean> endComposition(DOMString text); |