Changes

Jump to: navigation, search

WebAPI/KeboardIME

496 bytes added, 13:50, 18 July 2013
Proposed API
// Input Method Manager contain a few global methods expose to apps
readonly attribute InputMethodManager mgmt;
// 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.
// Note that if the app saves the original context, it might get void; implementation decides when to void the input context.
attribute EventHandler oninputcontextchange;
// 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.
// OS should ignore this request if the app is 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 the app is currently not the active one.
void next();
// Clear the focus of the current input field.
// The OS might respond with hidden of the virtual keyboard and void the input context.
// 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.
// [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 {
// The tag name of input field, which is enum of "input", "textarea", or "contenteditable"
DOMString name;
// 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
DOMString type;
/*
* The inputmode string, representing the input mode.
*/
DOMString inputmode;
/*
* The primary language for the input field.
*/
DOMString lang;
/*
* Get the whole text content of the input field.
*/
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.
*/
Promise<boolean> setSelectionRange(long start, long 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?
* text change event.
attribute EventHandler onselectionchange;
/*
* Get the text content around the cursor of the input field.
*/
Promise<DOMString beforeText, DOMString afterText> getSurroundingText();
/*
*
*/
Promise<boolean> deleteSurroundingText(long offset, long length);
/*
* This event is sent when the text around the cursor is changed, due to either text
*/
attribute SurroundingTextChangeEventHandler onsurroundingtextchange;
/*
* send a character with its key events.
*/
Promise<boolean> sendKey(long keyCode, long charCode, long modifiers);
/*
* Set current composition. It will start or update composition.
* [JJ] Dont really know about this, but what if endComposition is never called
* 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);
/*
* endComposition and actually commit the text.
Confirm
478
edits

Navigation menu