WebAPI/KeboardIME: Difference between revisions

Jump to navigation Jump to search
comments of Yuan
(comments of Yuan)
Line 82: Line 82:
     // [JJ] What is removeFocus doing here. Everything that interacts with form elements
     // [JJ] What is removeFocus doing here. Everything that interacts with form elements
     //      happens in the inputContext, so this should be there too.
     //      happens in the inputContext, so this should be there too.
    // [yxl] Agree with JJ. It needs be under InputContext.
     void removeFocus();
     void removeFocus();
   };
   };
Line 122: Line 123:
     * [JJ] Do we have any case where loading the full text is required?
     * [JJ] Do we have any case where loading the full text is required?
     *      I don't see it in the example code.
     *      I don't see it in the example code.
    * [yxl] No, but in case any IME needs.
     */
     */
     Promise<DOMString> getText();
     Promise<DOMString> getText();
Line 141: Line 143:
       * [JJ] I think that this method should return the same info as the selectionchange event
       * [JJ] I think that this method should return the same info as the selectionchange event
       *      rather than a boolean.
       *      rather than a boolean.
      * [yxl] I don't think so. We could get selection range info by checking the attributes of
      *      selectionStart and selectionEnd.
       */
       */
     Promise<boolean> setSelectionRange(long start, long length);
     Promise<boolean> setSelectionRange(long start, long length);
Line 150: Line 154:
       *      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;
   
   
Line 157: Line 162:
     * App is encouraged to use this instead of getText() above to prevent getting to much things clogged in memory.
     * App is encouraged to use this instead of getText() above to prevent getting to much things clogged in memory.
     * TODO: how to return two values in one Promise object? as two arguments to the callback?
     * TODO: how to return two values in one Promise object? as two arguments to the callback?
    * [yxl] Impossible to return two value, but can wrap the two value with an object.
    *      Another option is to divide this method into two methods - getTextBeforeCursor and getTextAfterCursor.
     *
     *
     * [JJ] Would be useful to also include other state info (cursor position, selection pos, etc.)
     * [JJ] Would be useful to also include other state info (cursor position, selection pos, etc.)
     *      So we have 1 state object that gets returned regardless of operation
     *      So we have 1 state object that gets returned regardless of operation
     *      (same one as in the change handlers and setSelectionRange)
     *      (same one as in the change handlers and setSelectionRange)  
    * [yxl] Not necessary. cursor position or selection pos can be get by the attributes of selectionStart
    *      and selectionEnd.
     */
     */
     Promise<DOMString beforeText, DOMString afterText> getSurroundingText();
     Promise<DOMString beforeText, DOMString afterText> getSurroundingText();
Line 172: Line 181:
       * [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);
Line 182: Line 193:
     * @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
     * 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.
     * 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|?
     * 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 208:
       * TODO: what does Promise object returns?
       * TODO: what does Promise object returns?
       * TODO2: what are the modifiers?
       * TODO2: what are the modifiers?
      * [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?
       * [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 211: Line 227:
   
   
     /*
     /*
      * [yx] I'd like to replace this method with commitText and add clearComposition to allow IME
      * to cancel composition.
       * endComposition and actually commit the text.
       * endComposition and actually commit the text.
       * Ending the composition with an empty string will not send any text.
       * Ending the composition with an empty string will not send any text.
Line 218: Line 236:
       */
       */
     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.
      *
      * @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);
  };
  };


Line 223: Line 251:


* For a simple virtual keyboard action (send a character and key events w/ each user action), use <code>sendKey()</code>. TODO: should we allow backspace key to be sent from the method? If not, how do send these non-printable characters and it's effect with key events?
* For a simple virtual keyboard action (send a character and key events w/ each user action), use <code>sendKey()</code>. TODO: should we allow backspace key to be sent from the method? If not, how do send these non-printable characters and it's effect with key events?
*[yxl] I perfer to allowing non-printable character, such as backspace key, to be sent, if there is no security issue. This
*      would give the IME more flexibility.
* For spellcheck, autocomplete etc, use surrounding text methods.
* For spellcheck, autocomplete etc, use surrounding text methods.
* For cursor moment helper features, use <code>setSelectionRange()</code> and related attributes.
* For cursor moment helper features, use <code>setSelectionRange()</code> and related attributes.
Confirmed users
58

edits

Navigation menu