Confirmed users
58
edits
m (→Proposed API) |
(change Promise<boolean> to Promise<void> and add textBeforeCursor, textAfterCursor properties.) |
||
Line 232: | Line 232: | ||
// Ask the OS to show a list of available IMEs for users to switch from. | // 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. | // OS should ignore this request if the app is currently not the active one. | ||
void | 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 | void next(); | ||
// To know if the OS supports IME switching or not. | // To know if the OS supports IME switching or not. | ||
Line 249: | Line 249: | ||
// This method belong to |mgmt| because we would like to allow Keyboard to access to | // This method belong to |mgmt| because we would like to allow Keyboard to access to | ||
// this method w/o a input context. | // this method w/o a input context. | ||
void | void hide(); | ||
}; | }; | ||
Line 268: | Line 268: | ||
// But I agree that also enabling the keyboard to declare in the manifest which types it supports | // But I agree that also enabling the keyboard to declare in the manifest which types it supports | ||
// is a good idea. | // is a good idea. | ||
interface | interface InputContext: EventTarget { | ||
// 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" | ||
readonly DOMString type; | |||
readonly DOMString | |||
// 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 | ||
readonly DOMString inputType; | |||
readonly DOMString | |||
/* | /* | ||
Line 284: | Line 280: | ||
* See http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#input-modalities:-the-inputmode-attribute | * See http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#input-modalities:-the-inputmode-attribute | ||
*/ | */ | ||
readonly DOMString inputMode; | readonly DOMString inputMode; | ||
Line 292: | Line 287: | ||
* See http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement | * See http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#htmlelement | ||
*/ | */ | ||
readonly DOMString lang; | readonly DOMString lang; | ||
Line 304: | Line 298: | ||
readonly attribute long selectionEnd; | readonly attribute long selectionEnd; | ||
// The text before and after the begining of the selected text. | |||
readonly attribute DOMString textBeforeCursor; | |||
readonly attribute DOMString textAfterCursor; | |||
/* | /* | ||
* Set the selection range of the the editable text. | * Set the selection range of the the editable text. | ||
Line 319: | Line 317: | ||
* selectionStart and selectionEnd. | * selectionStart and selectionEnd. | ||
*/ | */ | ||
Promise<boolean> setSelectionRange(long start, long length); | <strike>Promise<boolean> setSelectionRange(long start, long length);</strike> | ||
Promise<void> setSelectionRange(long start, long length); | |||
/* User moves the cursor, or changes the selection with other means. If the text around | /* User moves the cursor, or changes the selection with other means. If the text around | ||
* cursor has changed, but the cursor has not been moved, the IME won't get notification. | * cursor has changed, but the cursor has not been moved, the IME won't get notification. | ||
*/ | */ | ||
attribute EventHandler onselectionchange; | attribute EventHandler onselectionchange; | ||
Line 337: | Line 332: | ||
* @param length The length of text to replace. Defaults to 0. | * @param length The length of text to replace. Defaults to 0. | ||
*/ | */ | ||
Promise<boolean> <strike> | <strike>Promise<boolean> replaceSurroundingText(DOMString text, [optional] long offset, [optional] long length);</strike> | ||
Promise<void> replaceSurroundingText(DOMString text, [optional] long offset, [optional] long length); | |||
/* | /* | ||
Line 344: | Line 340: | ||
* @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. | ||
*/ | */ | ||
Promise<boolean> deleteSurroundingText(long offset, long length); | <strike>Promise<boolean> deleteSurroundingText(long offset, long length);</strike> | ||
Promise<void> deleteSurroundingText(long offset, long length); | |||
/* | /* | ||
Line 354: | Line 348: | ||
* editing or cursor movement. If the cursor has been moved, but the text around has not | * editing or cursor movement. If the cursor has been moved, but the text around has not | ||
* changed, the IME won't get notification. | * changed, the IME won't get notification. | ||
*/ | */ | ||
// [JS] Can you describe how the cursor can be moved without the surrounding text | // [JS] Can you describe how the cursor can be moved without the surrounding text | ||
// also changing? Is that really something that can happen? | // also changing? Is that really something that can happen? | ||
// [yxl] For example, if the text field is filled with 'a', wherever the cusor movies the surrounding text is always 'aa...'. | // [yxl] For example, if the text field is filled with 'a', wherever the cusor movies the surrounding text is always 'aa...'. Another exmaple, the selection range is changed, but the cursor isn't and the surrouding text won't be changed. | ||
attribute | attribute EventHandler onsurroundingtextchange; | ||
/* | /* | ||
Line 373: | Line 360: | ||
* Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object. | * Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object. | ||
*/ | */ | ||
Promise<boolean> sendKey(long keyCode, long charCode, [optional] long modifiers); | <strike>Promise<boolean> sendKey(long keyCode, long charCode, [optional] long modifiers);</strike> | ||
Promise<void> sendKey(long keyCode, long charCode, [optional] long modifiers); | |||
/* | /* | ||
Line 396: | Line 384: | ||
* To finish composition and commit text to current input field, an IME should call |endComposition|. | * To finish composition and commit text to current input field, an IME should call |endComposition|. | ||
*/ | */ | ||
<strike> | <strike>Promise<boolean> setComposition(DOMString text, [optional] long cursor);</strike> | ||
Promise<void> setComposition(DOMString text, [optional] long cursor); | |||
Promise< | |||
/* | /* | ||
Line 410: | Line 397: | ||
* |replaceSurroundingText|, |deleteSurroundingText|, user moving the cursor, changing the focus, etc. | * |replaceSurroundingText|, |deleteSurroundingText|, user moving the cursor, changing the focus, etc. | ||
*/ | */ | ||
Promise<boolean> endComposition(DOMString text); | <strike>Promise<boolean> endComposition(DOMString text);</strike> | ||
Promise<void> endComposition(DOMString text); | |||
}; | }; | ||