Confirmed users
58
edits
m (Adjust indentation) |
m (→Proposed API) |
||
Line 51: | Line 51: | ||
}; | }; | ||
interface InputMethod: EventTarget { | |||
interface | // Input Method Manager contain a few global methods expose to apps | ||
// | readonly attribute InputMethodManager mgmt; | ||
// 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; | |||
// 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; | |||
// Fired when the input context changes, include changes from and to null. | |||
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 | |||
* editing or cursor movement. The text length is limited to 100 characters for each | |||
* back and forth direction. | |||
* | |||
* The event handler function is specified as: | |||
* @param beforeString Text before and including cursor position. | |||
* @param afterString Text after and excluing cursor position. | |||
* 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 | // 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; | |||
}; | }; | ||