Confirmed users
478
edits
m (→Examples) |
|||
Line 94: | Line 94: | ||
// 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 101: | Line 101: | ||
DOMString inputmode; | 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 | DOMString lang; | ||
/* | |||
* Get the whole text content of the input field. | |||
* App is encouraged to use getSurroundingText() below to prevent getting to much things clogged in memory. | |||
*/ | |||
Promise<DOMString> getText(); | |||
// The start and stop position of the selection. | |||
readonly attribute long selectionStart; | |||
readonly attribute long selectionEnd; | |||
/* | /* | ||
* | * Set the selection range of the the editable text. | ||
* | * Note: This method cannot be used to move the cursor during composition. Calling this | ||
* | * method will cancel composition. | ||
* @param start The beginning of the selected text. | |||
* @param length The length of the selected text. | |||
* | * | ||
* | * Note that the start position should be less or equal to the end position. | ||
* To move the cursor, set the start and end position to the same value. | |||
* | |||
*/ | */ | ||
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? | |||
attribute EventHandler onselectionchange; | attribute EventHandler onselectionchange; | ||
/* | |||
* Get the text content around the cursor of the input field. | |||
* The text length is limited to 100 characters for each back and forth direction. | |||
* App is encouraged to use this instead of getText() above to prevent getting to much things clogged in memory. | |||
* TODO: how to return two values in one Promise object? as two arguments to the callback? | |||
*/ | |||
Promise<DOMString beforeText, DOMString afterText> getSurroundingText(); | |||
Promise< | |||
/* | /* | ||
* | * | ||
Line 148: | Line 147: | ||
* @param offset The offset from the cursor position where deletion starts. | * @param offset The offset from the cursor position where deletion starts. | ||
* @param length The length of text to delete. | * @param length The length of text to delete. | ||
* TODO: maybe updateSurroundingText(DOMString beforeText, DOMString afterText); ? | |||
*/ | */ | ||
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 | |||
* editing or cursor movement. | |||
* | |||
* The event handler function is specified as: | |||
* @param beforeString Text before and including cursor position. | |||
* @param afterString Text after and excluing cursor position. | |||
* function(DOMString beforeText, DOMString afterText) { | |||
* ... | |||
* } | |||
Promise<boolean> | * TODO: Is this a DOM Event or an attribute allows callback attachment? We should align the wording here. | ||
* TODO2: should this be |oncursorpositionchange|? | |||
*/ | |||
attribute SurroundingTextChangeEventHandler onsurroundingtextchange; | |||
/* | |||
* send a character with its key events. | |||
* TODO: what does Promise object returns? | |||
* TODO2: what are the modifiers? | |||
* Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object. | |||
*/ | |||
Promise<boolean> sendKey(long keyCode, long charCode, long modifiers); | |||
/* | /* | ||
Line 174: | Line 181: | ||
/* | /* | ||
* | * endComposition and actually commit the text. | ||
* | * Ending the composition with an empty string will not send any text. | ||
* (was |commitText(text, offset, length)|) | |||
* | |||
* @param text The text | |||
*/ | */ | ||
Promise<boolean> | Promise<boolean> endComposition(DOMString text); | ||
}; | }; | ||