Confirmed users
58
edits
m (→Proposed API) |
m (→Examples) |
||
Line 97: | Line 97: | ||
== Examples == | == Examples == | ||
var conn = navigator.mozInputMethodConnection; | |||
// Called when the user starts or finishes editing an input field | |||
conn.oninputmethodstatechange= function(event) { | |||
if (conn.inputStarted) { | |||
// Text input should start | |||
} else { | |||
// Text input should end | |||
} | |||
}; | |||
// Insert a string at the current cursor position | |||
conn.commitText('Hello world'); | |||
// Get the selected text | |||
conn.getText(conn.selectionStart, conn.selectionEnd, function callback(text) { | |||
var selectedText = text; | |||
}); | |||
// Move the cursor position | |||
var position = 10; | |||
conn.setSelectionRange(position, position); | |||
// Hide the keyboard | |||
conn.removeFocus(); | |||
// Switch the focus onto the next input field if possible | |||
if (conn.canAdvanceFocus) { | |||
conn.advanceFocus(); | |||
} | |||
== Related == | == Related == |