Confirmed users
478
edits
Janjongboom (talk | contribs) (Add comments by me) |
|||
| Line 56: | 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. | ||
// The new InputContext instance will be available in the event object under |inputcontext| property. | // The new InputContext instance will be available in the event object under |inputcontext| property. | ||
| Line 62: | Line 62: | ||
// Note that if the app saves the original context, it might get void; implementation decides when to void the input context. | // Note that if the app saves the original context, it might get void; implementation decides when to void the input context. | ||
attribute EventHandler oninputcontextchange; | 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. | ||
| Line 73: | Line 73: | ||
// OS should ignore this request if the app is currently not the active one. | // OS should ignore this request if the app is currently not the active one. | ||
void showAll(); | void showAll(); | ||
// Ask the OS to switch away from the current active Keyboard app. | // 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. | // OS should ignore this request if the app is currently not the active one. | ||
void next(); | void next(); | ||
// Clear the focus of the current input field. | // Clear the focus of the current input field. | ||
// The OS might respond with hidden of the virtual keyboard and void the input context. | // The OS might respond with hidden of the virtual keyboard and void the input context. | ||
| Line 94: | Line 94: | ||
// The system should guarantee that the right view is rendered based on entry_points in | // The system should guarantee that the right view is rendered based on entry_points in | ||
// in manifest (e.g. navigate keyboard to #text/en, or something, based on manifest. | // in manifest (e.g. navigate keyboard to #text/en, or something, based on manifest. | ||
// [Tim] I don't think they are exclusive. A keyboard app might choose to load the same page with the same hash | |||
// for different types but only to deal with the |type| or |inputmode| difference later. | |||
interface InputContext { | 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; | ||
// The type of the input field, which is enum of text, number, password, url, search, email, and so on. | // 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 | // 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 107: | Line 109: | ||
*/ | */ | ||
DOMString inputmode; | DOMString inputmode; | ||
/* | /* | ||
* The primary language for the input field. | * The primary language for the input field. | ||
| Line 114: | Line 116: | ||
*/ | */ | ||
DOMString lang; | DOMString lang; | ||
/* | /* | ||
* Get the whole text content of the input field. | * Get the whole text content of the input field. | ||
| Line 122: | Line 124: | ||
*/ | */ | ||
Promise<DOMString> getText(); | Promise<DOMString> getText(); | ||
// The start and stop position of the selection. | // The start and stop position of the selection. | ||
readonly attribute long selectionStart; | readonly attribute long selectionStart; | ||
readonly attribute long selectionEnd; | readonly attribute long selectionEnd; | ||
/* | /* | ||
* Set the selection range of the the editable text. | * Set the selection range of the the editable text. | ||
| Line 141: | Line 143: | ||
*/ | */ | ||
Promise<boolean> setSelectionRange(long start, long length); | 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? | * TODO: dup with the onsurroundingtextchange event/callback below for cursor moment? | ||
| Line 149: | Line 151: | ||
* text change event. | * text change event. | ||
attribute EventHandler onselectionchange; | attribute EventHandler onselectionchange; | ||
/* | /* | ||
* Get the text content around the cursor of the input field. | * Get the text content around the cursor of the input field. | ||
| Line 161: | Line 163: | ||
*/ | */ | ||
Promise<DOMString beforeText, DOMString afterText> getSurroundingText(); | Promise<DOMString beforeText, DOMString afterText> getSurroundingText(); | ||
/* | /* | ||
* | * | ||
| Line 172: | Line 174: | ||
*/ | */ | ||
Promise<boolean> deleteSurroundingText(long offset, long length); | Promise<boolean> deleteSurroundingText(long offset, long length); | ||
/* | /* | ||
* 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 187: | Line 189: | ||
*/ | */ | ||
attribute SurroundingTextChangeEventHandler onsurroundingtextchange; | attribute SurroundingTextChangeEventHandler onsurroundingtextchange; | ||
/* | /* | ||
* send a character with its key events. | * send a character with its key events. | ||
| Line 196: | Line 198: | ||
*/ | */ | ||
Promise<boolean> sendKey(long keyCode, long charCode, long modifiers); | Promise<boolean> sendKey(long keyCode, long charCode, long modifiers); | ||
/* | /* | ||
* Set current composition. It will start or update composition. | * Set current composition. It will start or update composition. | ||
| Line 202: | Line 204: | ||
* [JJ] Dont really know about this, but what if endComposition is never called | * [JJ] Dont really know about this, but what if endComposition is never called | ||
* maybe because unhandled exception? | * maybe because unhandled exception? | ||
* [Tim] If that happens the API implementation should automatically ends the composition | |||
* session (with event and confirm the current composition). Same apply when the inputContext is lost | |||
* during a unfinished composition session. | |||
*/ | */ | ||
Promise<boolean> setComposition(DOMString text, long cursor); | Promise<boolean> setComposition(DOMString text, long cursor); | ||
/* | /* | ||
* endComposition and actually commit the text. | * endComposition and actually commit the text. | ||