WebAPI/KeboardIME: Difference between revisions

m
m (Adjust indentation)
Line 51: Line 51:
  };
  };


// Manages the list of IMEs, enables/disables IME and switches to an IME.
  interface InputMethod: EventTarget {
  interface InputMethodManager {
     // Input Method Manager contain a few global methods expose to apps
     // Ask the OS to show a list of available IMEs for users to switch from.
     readonly attribute InputMethodManager mgmt;
    // OS should ignore this request if we are currently not the active one.
    void showAll();
    // Ask the OS to switch away from the current active Keyboard app.
    // OS should ignore this request if we are currently not the active one.
    void next();
  };
 
// The input context, which consists of attributes and information of current input field.
// An "input context" gets void when the app is no longer allowed to interact with the text field,
// e.g., the text field does no longer exist, the app is being switched to background, and etc.
interface InputContext {
    // The tag name of input field, which is enum of "input", "textarea", or "contenteditable"
    DOMString name;
 
    // The type of the input field, which is enum of text, number, password, url, search and email.
    DOMString type;
 
    /*
    * The input mode string.
    * https://bugzilla.mozilla.org/show_bug.cgi?id=796544
    * It can be one of the following values:
    * "none"
    * "verbatim"    - no capitalization, no word suggestions
    * "latin"      - word suggestions but no capitalization
    * "latin-prose" - word suggestions and capitalization at the start of sentences
    * "latin-name"  - word suggestions and capitalize each word
    * "digit"      - digits(0-9) only.
    */
    DOMString inputmode;
 
    /*
    * The primary language for the input field.
    * It is the value of HTMLElement.lang.
    * see http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement
     */
    DOMString lang;
};


interface InputMethod: EventTarget {
    // It informs the IME that text input has started in an input field. If the IME is activated, this event is sent when focus enters a new input field. Otherwise this event is sent when user switches to the IME and activates it.
    // It informs the IME that text input has started in an input field. If the IME is activated, this event is sent when focus enters a new input field. Otherwise this event is sent when user switches to the IME and activates it.
    attribute EventHandler onstart;
    attribute EventHandler onstart;
   
   
    // It informs the IME that text input has finished in last input field. This event is sent when focus leaves current input field or user switches to another IME.
    // It informs the IME that text input has finished in last input field. This event is sent when focus leaves current input field or user switches to another IME.
    attribute EventHandler onfinish;
    attribute EventHandler onfinish;
   
   
    // Fired when the input context changes, include changes from and to null.
    // Fired when the input context changes, include changes from and to null.
    attribute EventHandler oncontextchange;
    attribute EventHandler oncontextchange;
 
    // An "input context" is mapped to a text field that the app is allow to mutate.
    // this attribute should be null when there is no text field currently focused.
    readonly attribute InputContext? inputcontext;
   
   
    /*
    /*
    * This event is sent when the text around the cursor is changed, due to either text
      * This event is sent when the text around the cursor is changed, due to either text
    * editing or cursor movement. The text length is limited to 100 characters for each
      * editing or cursor movement. The text length is limited to 100 characters for each
    * back and forth direction.
      * back and forth direction.
    *
      *
    * 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.
    * function(long contextId, DOMString beforeText, DOMString afterText) {
      * function(long contextId, DOMString beforeText, DOMString afterText) {
    * ...
      * ...
    *  }
      *  }
    */
      */
     attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
     attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
   
   
Line 176: Line 141:
     // Clear the focus of the current input field and hide the keyboard.
     // Clear the focus of the current input field and hide the keyboard.
     Promise<boolean> removeFocus();
     Promise<boolean> removeFocus();
};
// Manages the list of IMEs, enables/disables IME and switches to an IME.
interface InputMethodManager {
    // Ask the OS to show a list of available IMEs for users to switch from.
    // OS should ignore this request if we are currently not the active one.
    void showAll();
   
   
     // The input method context
     // Ask the OS to switch away from the current active Keyboard app.
    // An "input context" is mapped to a text field that the app is allow to mutate.
    // OS should ignore this request if we are currently not the active one.
     // this attribute should be null when there is no text field currently focused.
    void next();
     readonly attribute InputContext? inputcontext;
  };
 
// The input context, which consists of attributes and information of current input field.
// An "input context" gets void when the app is no longer allowed to interact with the text field,
// e.g., the text field does no longer exist, the app is being switched to background, and etc.
interface InputContext {
    // The tag name of input field, which is enum of "input", "textarea", or "contenteditable"
    DOMString name;
 
    // The type of the input field, which is enum of text, number, password, url, search and email.
    DOMString type;
 
    /*
     * The input mode string.
    * https://bugzilla.mozilla.org/show_bug.cgi?id=796544
    * It can be one of the following values:
    * "none"
    * "verbatim"    - no capitalization, no word suggestions
    * "latin"      - word suggestions but no capitalization
    * "latin-prose" - word suggestions and capitalization at the start of sentences
    * "latin-name"  - word suggestions and capitalize each word
    * "digit"      - digits(0-9) only.
    */
    DOMString inputmode;
 
    /*
    * The primary language for the input field.
     * It is the value of HTMLElement.lang.
    * see http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement
    */
    DOMString lang;
  };
  };


Confirmed users
58

edits