WebAPI/KeboardIME: Difference between revisions

(comments of Yuan)
Line 78: Line 78:
     void next();
     void next();
   
   
     // Clear the focus of the current input field.
     // Ask the OS to hide the current active Keyboard app. (was: |removeFocus()|)
     // The OS might respond with hidden of the virtual keyboard and void the input context.
    // OS should ignore this request if the app is currently not the active one.
     // [JJ] What is removeFocus doing here. Everything that interacts with form elements
     // The OS will void the current input context (if it exists).
     //     happens in the inputContext, so this should be there too.
     // This method belong to |mgmt| because we would like to allow Keyboard to access to
    // [yxl] Agree with JJ. It needs be under InputContext.
     // this method w/o a input context.
     void removeFocus();
     void hide();
   };
   };


Line 119: Line 119:
   
   
     /*
     /*
     * Get the whole text content of the input field.
     * Get the whole text content of the input field. (|getSurroundingText()| is removed in favor of this method with params)
    * App is encouraged to use getSurroundingText() below to prevent getting to much things clogged in memory.
    * [JJ] Do we have any case where loading the full text is required?
    *      I don't see it in the example code.
    * [yxl] No, but in case any IME needs.
     */
     */
     Promise<DOMString> getText();
     Promise<DOMString> getText([optional] offset, [optional] length);
   
   
     // The start and stop position of the selection.
     // The start and stop position of the selection.
Line 148: Line 144:
     Promise<boolean> setSelectionRange(long start, long length);
     Promise<boolean> setSelectionRange(long start, long length);
   
   
     /* User moves the cursor, changes the selection, or alters the composing text length
     /* User moves the cursor, or changes the selection with other means
       * TODO: dup with the onsurroundingtextchange event/callback below for cursor moment?
       * TODO: dup with the onsurroundingtextchange event/callback below for cursor moment?
       *
       *
Line 155: Line 151:
       *      text change event.
       *      text change event.
       * [yxl] remove this and merge with onsurroundingtextchange
       * [yxl] remove this and merge with onsurroundingtextchange
      */
     attribute EventHandler onselectionchange;
     attribute EventHandler onselectionchange;
    /*
    * Get the text content around the cursor of the input field.
    * The text length is limited to 100 characters for each back and forth direction.
    * 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?
    * [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.)
    *      So we have 1 state object that gets returned regardless of operation
    *      (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();
   
   
     /*
     /*
Line 194: Line 175:
     * @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
     * [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) {
     * ...
     * ...
Line 227: Line 209:
   
   
     /*
     /*
       * [yx] I'd like to replace this method with commitText and add clearComposition to allow IME
       * End composition and actually commit the text. (was |commitText(text, offset, length)|)
      * to cancel composition.
      * 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.
       * (was |commitText(text, offset, length)|)
       * Note that if composition always ends automatically (with the current composition committed) if the composition
      * did not explicitly with |endComposition()| but was interrupted with |sendKey()|, |setSelectionRange()|,
      * user moving the cursor, or remove the focus, etc.
       *
       *
       * @param text The text
       * @param text The text
Line 240: Line 222:
       * [yxl]
       * [yxl]
       * Commit text to current input field and replace text around cursor position. It will clear the current composition.
       * 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 text The string to be replaced with.
Confirmed users
478

edits