WebAPI/KeboardIME: Difference between revisions

Jump to navigation Jump to search
m
Line 150: Line 150:
     Promise<boolean> setSelectionRange(long start, long length);
     Promise<boolean> setSelectionRange(long start, long length);
   
   
     /* User moves the cursor, or changes the selection with other means
     /* User moves the cursor, or changes the selection with other means. If the text around
       * TODO: dup with the onsurroundingtextchange event/callback below for cursor moment?
       * cursor has changed, but the cursor has not been moved, the IME won't get notification.
       *
       *
       * [JJ] I would merge this with onsurroundingtextchange to have 1 state event.
       * [JJ] I would merge this with onsurroundingtextchange to have 1 state event.
       *      in the end, every onselectionchange event will also generate a surrounding
       *      in the end, every onselectionchange event will also generate a surrounding
       *      text change event.
       *      text change event.
      * [yxl] remove this and merge with onsurroundingtextchange
       */
       */
     attribute EventHandler onselectionchange;
     attribute EventHandler onselectionchange;
   
   
    /*
      * Commit text to current input field and replace text around cursor position. It will clear the current composition.
      *
      * @param text The string to be replaced with.
      * @param offset The offset from the cursor position where replacing starts. Defaults to 0.
      * @param length The length of text to replace. Defaults to 0.
      */
      Promise<boolean> replaceSurroundingText(DOMString text, [optional] long offset, [optional] long length);
     /*
     /*
       *
       *
Line 168: Line 176:
       * [JJ] Rather do a replaceSurroundingText(long offset, long length, optional DOMString text)
       * [JJ] Rather do a replaceSurroundingText(long offset, long length, optional DOMString text)
       *      If text is null or empty, it behaves the same
       *      If text is null or empty, it behaves the same
      * [yxl] We changed the name of replaceSurroundingText to commitText. commitText will do the
      *      work of updateSurroundingText.
       */
       */
     Promise<boolean> deleteSurroundingText(long offset, long length);
     Promise<boolean> deleteSurroundingText(long offset, long length);
   
   
     /*
     /*
     * This event is sent when the text around the cursor is changed, due to either text
     * Notifies when the text around the cursor is changed, due to either text
     * editing or cursor movement.
     * editing or cursor movement. If the cursor has been moved, but the text around has not
    * changed, the IME won't get notification.
     *
     *
     * The event handler function is specified as:
     * The event handler function is specified as:
     * @param beforeString Text before and including cursor position.
     * @param beforeString Text before and including cursor position.
     * @param afterString Text after and excluing cursor position.
     * @param afterString Text after and excluing cursor position.
    * [yxl] To combine with onselectionchange, we need add two extra paramters - selectionStart, selectionEnd
    * [Tim] That would unfortunately make the callback comes with 5 parameters ... people should use the attributes instead.
     * function(DOMString beforeText, DOMString afterText) {
     * function(DOMString beforeText, DOMString afterText) {
     * ...
     * ...
     *  }
     *  }
    * TODO: Is this a DOM Event or an attribute allows callback attachment? We should align the wording here.
    * [yxl]: An attribute allows callback attachment.
    * TODO2: should this be |oncursorpositionchange|?
    * [yxl]: No, the cursor may not move when the surrounding text changes.
     */
     */
     attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
     attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
Line 194: Line 195:
     /*
     /*
       * send a character with its key events.
       * send a character with its key events.
       * TODO: what does Promise object returns?
       * @param modifiers see http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl#206
      * TODO2: what are the modifiers?
      * @return true if succeeds. Otherwise false if the input context becomes void.
      * [yxl] http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl#206
       * 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.
      * [JJ] Why does this return anything?
      * [yxl] sendKey may fail if the input context becomes void.
       */
       */
     Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
     Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
Line 206: Line 204:
       * Set current composition. It will start or update composition.
       * Set current composition. It will start or update composition.
       * @param cursor Position in the text of the cursor.
       * @param cursor Position in the text of the cursor.
       * [JJ] Dont really know about this, but what if endComposition is never called
       *
       *     maybe because unhandled exception?
       * The API implementation should automatically ends the composition
      * [Tim] If that happens the API implementation should automatically ends the composition
       * session (with event and confirm the current composition) if
       *           session (with event and confirm the current composition). Same apply when the inputContext is lost
      * endComposition is never called. Same apply when the inputContext is lost
       *           during a unfinished composition session.
       * during a unfinished composition session.
       */
       */
     Promise<boolean> setComposition(DOMString text, long cursor);
     Promise<boolean> setComposition(DOMString text, long cursor);
Line 224: Line 222:
       */
       */
     Promise<boolean> endComposition(DOMString text);
     Promise<boolean> endComposition(DOMString text);
    /*
      * [yxl]
      * Commit text to current input field and replace text around cursor position. It will clear the current composition.
      * [Tim] Remove this method.
      *
      * @param text The string to be replaced with.
      * @param offset The offset from the cursor position where replacing starts. Defaults to 0.
      * @param length The length of text to replace. Defaults to 0.
      */
      Promise<boolean> commitText(DOMString text, [optional] long offset, [optional] long length);
  };
  };


Confirmed users
58

edits

Navigation menu