Confirmed users
478
edits
m (→Proposed API) |
|||
Line 46: | Line 46: | ||
== Proposed API == | == Proposed API == | ||
The input method API is available to web content who intend to implement an input method, or "input source", or "virtual keyboard". | |||
partial interface Navigator { | partial interface Navigator { | ||
Line 54: | Line 56: | ||
// Input Method Manager contain a few global methods expose to apps | // Input Method Manager contain a few global methods expose to apps | ||
readonly attribute InputMethodManager mgmt; | readonly attribute InputMethodManager mgmt; | ||
// 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 | // When it changes to null it means the app (the user of this API) no longer has the control of the original focused input field. | ||
// Note that if the app saves the original context, it might get void; implementation decides when to void the input context. | |||
attribute EventHandler oninputcontextchange; | |||
// An "input context" is mapped to a text field that the app is allow to mutate. | // 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. | // this attribute should be null when there is no text field currently focused. | ||
readonly attribute InputContext? inputcontext; | readonly attribute InputContext? inputcontext; | ||
}; | |||
// 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 the app is 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 the app is currently not the active one. | |||
void next(); | |||
// Clear the focus of the current input field. | |||
// The OS might respond with hidden of the virtual keyboard and void the input context. | |||
void removeFocus(); | |||
}; | |||
// The input context, which consists of attributes and information of current input field. | |||
// It also hosts the methods available to the keyboard app to mutate the input field represented. | |||
// 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, email, and so on. | |||
// See http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#states-of-the-type-attribute | |||
DOMString type; | |||
/* | |||
* The inputmode string, representing the input mode. | |||
* See http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#input-modalities:-the-inputmode-attribute | |||
*/ | |||
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; | |||
/* | /* | ||
* 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 | ||
Line 79: | Line 115: | ||
* @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( | * function(DOMString beforeText, DOMString afterText) { | ||
* ... | * ... | ||
* } | * } | ||
Line 141: | Line 177: | ||
*/ | */ | ||
Promise<boolean> clearComposition(); | Promise<boolean> clearComposition(); | ||
}; | }; | ||