Confirmed users
58
edits
(→Proposed API: Update proposed API to the latest one posted on dev-webapi) |
|||
Line 48: | Line 48: | ||
partial interface Navigator { | partial interface Navigator { | ||
readonly attribute | readonly attribute InputMethod inputMethod; | ||
}; | }; | ||
// Manages the list of IMEs, enables/disables IME and switches to an IME. | // Manages the list of IMEs, enables/disables IME and switches to an IME. | ||
interface InputMethodManager { | 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(); | |||
// | |||
// | // 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 | // 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" | // The tag name of input field, which is enum of "input", "textarea", or "contenteditable" | ||
DOMString name; | DOMString name; | ||
Line 121: | Line 90: | ||
}; | }; | ||
interface | 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; | ||
Line 128: | Line 97: | ||
attribute EventHandler onfinish; | attribute EventHandler onfinish; | ||
// | // Fired when the input context changes, include changes from and to null. | ||
attribute EventHandler oncontextchange; | attribute EventHandler oncontextchange; | ||
Line 149: | Line 118: | ||
// TODO: maybe the parameters could be simpler? | // TODO: maybe the parameters could be simpler? | ||
Promise<boolean> sendKey( | Promise<boolean> sendKey(long keyCode, long charCode, long modifiers); | ||
// Or Promise<boolean> sendKey( | // Or Promise<boolean> sendKey(KeyboardEvent event) | ||
/* | /* | ||
* Get the whole text content of the input field. | * Get the whole text content of the input field. | ||
*/ | */ | ||
Promise<DOMString> getText( | Promise<DOMString> getText(); | ||
/* | /* | ||
Line 164: | Line 133: | ||
* @param length The length of text to replace. Defaults to 0. | * @param length The length of text to replace. Defaults to 0. | ||
*/ | */ | ||
Promise<boolean> commitText( | Promise<boolean> commitText(DOMString text, [optional] long offset, [optional] long length); | ||
/* | /* | ||
Line 188: | Line 157: | ||
* To move the cursor, set the start and end position to the same value. | * To move the cursor, set the start and end position to the same value. | ||
*/ | */ | ||
Promise<boolean> setSelectionRange( | Promise<boolean> setSelectionRange(long start, long length); | ||
/* | /* | ||
Line 194: | Line 163: | ||
* @param cursor Position in the text of the cursor. | * @param cursor Position in the text of the cursor. | ||
*/ | */ | ||
Promise<boolean> setComposition( | Promise<boolean> setComposition(DOMString text, long cursor); | ||
/* | /* | ||
Line 200: | Line 169: | ||
* Use commitText to end composition and commit text. | * Use commitText to end composition and commit text. | ||
*/ | */ | ||
Promise<boolean> clearComposition( | Promise<boolean> clearComposition(); | ||
// 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(); | ||
// The input method context | // The input method context | ||
readonly attribute | // 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; | |||
}; | }; | ||
[TreatNonCallableAsNull] | [TreatNonCallableAsNull] | ||
callback SurroundingTextChangeEventHandlerNonNull = void ( | callback SurroundingTextChangeEventHandlerNonNull = void (DOMString beforeText, DOMString afterText); | ||
typedef SurroundingTextChangeEventHandlerNonNull? SurroundingTextChangeEventHandler; | typedef SurroundingTextChangeEventHandlerNonNull? SurroundingTextChangeEventHandler; | ||