WebAPI/KeboardIME: Difference between revisions

Jump to navigation Jump to search
m
detailed description of setComposition and endComposition
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 void.
       * @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 composition. It will start or update composition.
       * Set current composing text. This method will start composition or update composition if it
       * @param cursor Position in the text of the 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 API implementation should automatically ends the composition
       * The composing text, which is shown with underlined style to distinguish from the existing text, is used
       * session (with event and confirm the current composition) if
      * to compose non-ASCII characters from keystrokes, e.g. Pinyin or Hiragana. The composing text is the
       * endComposition is never called. Same apply when the inputContext is lost
       * intermediate text to help input complex character and is not committed to current input field. Therefore
       * during a unfinished composition session.
      * 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 actually commit the text. (was |commitText(text, offset, length)|)
       * End composition, clear the composing text and commit given text to current input field. The text will
      * Ending the composition with an empty string will not send any text.
       * be committed before the cursor position.
       * Note that if composition always ends automatically (with the current composition committed) if the composition
       * @param text The text to commited before cursor position. If empty string is given, no text will be
       * did not explicitly with |endComposition()| but was interrupted with |sendKey()|, |setSelectionRange()|,
       * committed.
       * user moving the cursor, or remove the focus, etc.
       *
       *
       * @param text The text
       * 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);
Confirmed users
58

edits

Navigation menu