WebAPI/KeboardIME: Difference between revisions

Jump to navigation Jump to search
Line 94: Line 94:
     // See http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#states-of-the-type-attribute
     // See http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#states-of-the-type-attribute
     DOMString type;
     DOMString type;
 
     /*
     /*
     * The inputmode string, representing the input mode.
     * The inputmode string, representing the input mode.
Line 101: Line 101:
     DOMString inputmode;
     DOMString inputmode;
    
    
    /*
    /*
      * The primary language for the input field.
    * The primary language for the input field.
      * It is the value of HTMLElement.lang.
    * It is the value of HTMLElement.lang.
      * See http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement
    * See http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement
      */
    */
     DOMString lang;
    DOMString lang;
 
    /*
     * Get the whole text content of the input field.
    * App is encouraged to use getSurroundingText() below to prevent getting to much things clogged in memory.
    */
    Promise<DOMString> getText();
 
    // The start and stop position of the selection.
    readonly attribute long selectionStart;
    readonly attribute long selectionEnd;
   
   
     /*
     /*
       * This event is sent when the text around the cursor is changed, due to either text
       * Set the selection range of the the editable text.
       * editing or cursor movement. The text length is limited to 100 characters for each
      * Note: This method cannot be used to move the cursor during composition. Calling this
       * back and forth direction.
       * method will cancel composition.
      * @param start The beginning of the selected text.
       * @param length The length of the selected text.
       *
       *
       * The event handler function is specified as:
       * Note that the start position should be less or equal to the end position.
      * @param beforeString Text before and including cursor position.
       * To move the cursor, set the start and end position to the same value.
       * @param afterString Text after and excluing cursor position.
      * function(DOMString beforeText, DOMString afterText) {
      * ...
      *  }
       */
       */
     attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
     Promise<boolean> setSelectionRange(long start, long length);
   
   
     // User moves the cursor, changes the selection, or alters the composing text length
     // User moves the cursor, changes the selection, or alters the composing text length
    // TODO: dup with the onsurroundingtextchange event/callback below for cursor moment?
     attribute EventHandler onselectionchange;
     attribute EventHandler onselectionchange;
   
   
    // TODO: maybe the parameters could be simpler?
    /*
    Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
     * Get the text content around the cursor of the input field.
    // Or Promise<boolean> sendKey(KeyboardEvent event)
     * 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?
      *  Get the whole text content of the input field.
    */
      */
     Promise<DOMString beforeText, DOMString afterText> getSurroundingText();
     Promise<DOMString> getText();
 
    /*
      * 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 148: Line 147:
       * @param offset The offset from the cursor position where deletion starts.
       * @param offset The offset from the cursor position where deletion starts.
       * @param length The length of text to delete.
       * @param length The length of text to delete.
      * TODO: maybe updateSurroundingText(DOMString beforeText, DOMString afterText); ?
       */
       */
     Promise<boolean> deleteSurroundingText(long offset, long length);
     Promise<boolean> deleteSurroundingText(long offset, long length);
   
   
    // The start and stop position of the selection.
    readonly attribute long selectionStart;
    readonly attribute long selectionEnd;
     /*
     /*
      * Set the selection range of the the editable text.
    * This event is sent when the text around the cursor is changed, due to either text
      * Note: This method cannot be used to move the cursor during composition. Calling this
    * editing or cursor movement.  
      * method will cancel composition.
    *
      * @param start The beginning of the selected text.
    * The event handler function is specified as:
      * @param length The length of the selected text.
    * @param beforeString Text before and including cursor position.
      *
    * @param afterString Text after and excluing cursor position.
      * Note that the start position should be less or equal to the end position.
    * function(DOMString beforeText, DOMString afterText) {
      * To move the cursor, set the start and end position to the same value.
    * ...
      */
    * }
     Promise<boolean> setSelectionRange(long start, long length);
    * TODO: Is this a DOM Event or an attribute allows callback attachment? We should align the wording here.
    * TODO2: should this be |oncursorpositionchange|?
    */
    attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
 
    /*
      * send a character with its key events.
      * TODO: what does Promise object returns?
      * TODO2: what are the modifiers?
      * Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object.
      */  
     Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
   
   
     /*
     /*
Line 174: Line 181:
   
   
     /*
     /*
       * Clear composition. Called to cancel composition.
       * endComposition and actually commit the text.
       * Use commitText to end composition and commit text.
      * Ending the composition with an empty string will not send any text.
       * (was |commitText(text, offset, length)|)
      *
      * @param text The text
       */
       */
     Promise<boolean> clearComposition();
     Promise<boolean> endComposition(DOMString text);
  };
  };


Confirmed users
478

edits

Navigation menu