Changes

Jump to: navigation, search

WebAPI/KeboardIME

884 bytes removed, 02:32, 23 July 2013
m
Proposed API
Promise<boolean> setSelectionRange(long start, long length);
/* User moves the cursor, or changes the selection with other means. If the text around * TODO: dup with cursor has changed, but the onsurroundingtextchange event/callback below for cursor moment?has not been moved, the IME won't get notification.
*
* [JJ] I would merge this with onsurroundingtextchange to have 1 state event.
* in the end, every onselectionchange event will also generate a surrounding
* text change event.
* [yxl] remove this and merge with onsurroundingtextchange
*/
attribute EventHandler onselectionchange;
/*
* Commit text to current input field and replace text around cursor position. It will clear the current composition.
*
* @param text The string to be replaced with.
* @param offset The offset from the cursor position where replacing starts. Defaults to 0.
* @param length The length of text to replace. Defaults to 0.
*/
Promise<boolean> replaceSurroundingText(DOMString text, [optional] long offset, [optional] long length);
 
/*
*
* [JJ] Rather do a replaceSurroundingText(long offset, long length, optional DOMString text)
* If text is null or empty, it behaves the same
* [yxl] We changed the name of replaceSurroundingText to commitText. commitText will do the
* work of updateSurroundingText.
*/
Promise<boolean> deleteSurroundingText(long offset, long length);
/*
* This event is sent Notifies when the text around the cursor is changed, due to either text * editing or cursor movement. If the cursor has been moved, but the text around has not * changed, the IME won't get notification.
*
* The event handler function is specified as:
* @param beforeString Text before and including cursor position.
* @param afterString Text after and excluing cursor position.
* [yxl] To combine with onselectionchange, we need add two extra paramters - selectionStart, selectionEnd
* [Tim] That would unfortunately make the callback comes with 5 parameters ... people should use the attributes instead.
* function(DOMString beforeText, DOMString afterText) {
* ...
* }
* TODO: Is this a DOM Event or an attribute allows callback attachment? We should align the wording here.
* [yxl]: An attribute allows callback attachment.
* TODO2: should this be |oncursorpositionchange|?
* [yxl]: No, the cursor may not move when the surrounding text changes.
*/
attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
/*
* send a character with its key events.
* TODO: what does Promise object returns? * TODO2: what are the @param modifiers? * [yxl] see http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl#206 * @return true if succeeds. Otherwise false if the input context becomes void.
* Alternative: sendKey(KeyboardEvent event), but we will likely waste memory for creating the KeyboardEvent object.
* [JJ] Why does this return anything?
* [yxl] sendKey may fail if the input context becomes void.
*/
Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
* Set current composition. It will start or update composition.
* @param cursor Position in the text of the cursor.
* [JJ] Dont really know about this, but what if endComposition is never called * maybe because unhandled exception? * [Tim] If that happens the The API implementation should automatically ends the composition * session (with event and confirm the current composition)if * endComposition is never called. Same apply when the inputContext is lost * during a unfinished composition session.
*/
Promise<boolean> setComposition(DOMString text, long cursor);
*/
Promise<boolean> endComposition(DOMString text);
 
/*
* [yxl]
* Commit text to current input field and replace text around cursor position. It will clear the current composition.
* [Tim] Remove this method.
*
* @param text The string to be replaced with.
* @param offset The offset from the cursor position where replacing starts. Defaults to 0.
* @param length The length of text to replace. Defaults to 0.
*/
Promise<boolean> commitText(DOMString text, [optional] long offset, [optional] long length);
};
Confirm
58
edits

Navigation menu