You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
WARNING: This is the BETA documentation. It may not work with the stable release of Chrome.
WARNING: This is unofficial documentation. It may not work with the current release of Chrome.

Google Chrome Extensions (Labs)

chrome.input.ime

API reference: chrome.input.ime

Methods

clearComposition

chrome.input.ime.clearComposition(object parameters, function callback)

Clear the current composition. If this extension does not own the active IME, this fails.

Parameters

parameters
( object )
Undocumented.
contextID
( integer )
ID of the context where the composition will be cleared
callback
( optional function )
Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.extension.lastError is set.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(boolean success) {...};
success
( boolean )
Undocumented.

commitText

chrome.input.ime.commitText(object parameters, function callback)

Commits the provided text to the current input.

Parameters

parameters
( object )
Undocumented.
contextID
( integer )
ID of the context where the text will be committed
text
( string )
The text to commit
callback
( optional function )
Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.extension.lastError is set.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(boolean success) {...};
success
( boolean )
Undocumented.

setCandidateWindowProperties

chrome.input.ime.setCandidateWindowProperties(object parameters, function callback)

Sets the properties of the candidate window. This fails if the extension doesn’t own the active IME

Parameters

parameters
( object )
Undocumented.
engineID
( string )
ID of the engine to set properties on.
properties
( object )
Undocumented.
visible
( optional boolean )
True to show the Candidate window, false to hide it.
cursorVisible
( optional boolean )
True to show the cursor, false to hide it.
vertical
( optional boolean )
True if the candidate window should be rendered vertical, false to make it horizontal.
pageSize
( optional integer )
The number of candidates to display per page.
auxiliaryText
( optional string )
Text that is shown at the bottom of the candidate window.
auxiliaryTextVisible
( optional boolean )
True to display the auxiliary text, false to hide it.
callback
( optional function )
Called when the operation completes.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(boolean success) {...};
success
( boolean )
Undocumented.

setCandidates

chrome.input.ime.setCandidates(object parameters, function callback)

Sets the current candidate list. This fails if this extension doesn’t own the active IME

Parameters

parameters
( object )
Undocumented.
contextID
( integer )
ID of the context that owns the candidate window.
candidates
( array of object )
List of candidates to show in the candidate window
candidate
( string )
The candidate
id
( integer )
The candidate's id
parentId
( optional integer )
The id to add these candidates under
label
( optional string )
Short string displayed to next to the candidate, often the shortcut key or index
annotation
( optional string )
Additional text describing the candidate
callback
( optional function )
Called when the operation completes.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(boolean success) {...};
success
( boolean )
Undocumented.

setComposition

chrome.input.ime.setComposition(object parameters, function callback)

Set the current composition. If this extension does not own the active IME, this fails.

Parameters

parameters
( object )
Undocumented.
contextID
( integer )
ID of the context where the composition text will be set
text
( string )
Text to set
selectionStart
( optional integer )
Position in the text that the selection starts at.
selectionEnd
( optional integer )
Position in the text that the selection ends at.
cursor
( integer )
Position in the text of the cursor.
segments
( optional array of object )
List of segments and their associated types.
start
( integer )
Index of the character to start this segment at
end
( integer )
Index of the character to end this segment after.
style
( enumerated string ["underline", "doubleUnderline"] )
How to render this segment
callback
( optional function )
Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.extension.lastError is set.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(boolean success) {...};
success
( boolean )
Undocumented.

setCursorPosition

chrome.input.ime.setCursorPosition(object parameters, function callback)

Set the position of the cursor in the candidate window. This is a no-op if this extension does not own the active IME.

Parameters

parameters
( object )
Undocumented.
contextID
( integer )
ID of the context that owns the candidate window.
candidateID
( integer )
ID of the candidate to select.
callback
( optional function )
Called when the operation completes

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(boolean success) {...};
success
( boolean )
Undocumented.

setMenuItems

chrome.input.ime.setMenuItems(object parameters, function callback)

Adds the provided menu items to the language menu when this IME is active.

Parameters

parameters
( object )
Undocumented.
engineID
( string )
ID of the engine to use
items
( array of object )
MenuItems to add. They will be added in the order they exist in the array.
id
( string )
String that will be passed to callbacks referencing this MenuItem.
label
( optional string )
Text displayed in the menu for this item.
style
( optional enumerated string ["none", "check", "radio", "separator"] )
Enum representing if this item is: none, check, radio, or a separator. Radio buttons between separators are considered grouped.
visible
( optional boolean )
Indicates this item is visible.
checked
( optional boolean )
Indicates this item should be drawn with a check.
enabled
( optional boolean )
Indicates this item is enabled.
callback
( optional function )
Undocumented.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function() {...};

updateMenuItems

chrome.input.ime.updateMenuItems(object parameters, function callback)

Updates the state of the MenuItems specified

Parameters

parameters
( object )
Undocumented.
engineID
( string )
ID of the engine to use
items
( array of object )
Array of MenuItems to update
id
( string )
String that will be passed to callbacks referencing this MenuItem.
label
( optional string )
Text displayed in the menu for this item.
style
( optional enumerated string ["none", "check", "radio", "separator"] )
Enum representing if this item is: none, check, radio, or a separator. Radio buttons between separators are considered grouped.
visible
( optional boolean )
Indicates this item is visible.
checked
( optional boolean )
Indicates this item should be drawn with a check.
enabled
( optional boolean )
Indicates this item is enabled.
callback
( optional function )
Called when the operation completes

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function() {...};

Events

onActivate

chrome.input.ime.onActivate.addListener(function(string engineID) {...});

This event is sent when an IME is activated. It signals that the IME will be receiving onKeyPress events.

Listener parameters

engineID
( string )
ID of the engine receiving the event

onBlur

chrome.input.ime.onBlur.addListener(function(integer contextID) {...});

This event is sent when focus leaves a text box. It is sent to all extensions that are listening to this event, and enabled by the user.

Listener parameters

contextID
( integer )
The ID of the text field that has lost focus. The ID is invalid after this call

onCandidateClicked

chrome.input.ime.onCandidateClicked.addListener(function(string engineID, integer candidateID, string button) {...});

This event is sent if this extension owns the active IME.

Listener parameters

engineID
( string )
ID of the engine receiving the event
candidateID
( integer )
ID of the candidate that was clicked.
button
( enumerated string ["left", "middle", "right"] )
Which mouse buttons was clicked.

onDeactivated

chrome.input.ime.onDeactivated.addListener(function(string engineID) {...});

This event is sent when an IME is deactivated. It signals that the IME will no longer be receiving onKeyPress events.

Listener parameters

engineID
( string )
ID of the engine receiving the event

onFocus

chrome.input.ime.onFocus.addListener(function(InputContext context) {...});

This event is sent when focus enters a text box. It is sent to all extensions that are listening to this event, and enabled by the user.

Listener parameters

context
( InputContext )
Describes the text field that has acquired focus.

onInputContextUpdate

chrome.input.ime.onInputContextUpdate.addListener(function(InputContext context) {...});

This event is sent when the properties of the current InputContext change, such as the the type. It is sent to all extensions that are listening to this event, and enabled by the user.

Listener parameters

context
( InputContext )
An InputContext object describing the text field that has changed.

onKeyEvent

chrome.input.ime.onKeyEvent.addListener(function(string engineID, KeyboardEvent keyData) {...});

This event is sent if this extension owns the active IME.

Listener parameters

engineID
( string )
ID of the engine receiving the event
keyData
( KeyboardEvent )
Data on the key event

Listener returns

( boolean )
True if the keystroke was handled, false if not

onMenuItemActivated

chrome.input.ime.onMenuItemActivated.addListener(function(string engineID, string name) {...});

Called when the user selects a menu item

Listener parameters

engineID
( string )
ID of the engine receiving the event
name
( string )
Name of the MenuItem which was activated

Types

KeyboardEvent

( object )
See http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent
type
( enumerated string ["keyup", "keydown"] )
One of keyup or keydown.
requestId
( string )
The ID of the request.
key
( string )
Value of the key being pressed
altKey
( optional boolean )
Whether or not the ALT key is pressed.
ctrlKey
( optional boolean )
Whether or not the CTRL key is pressed.
shiftKey
( optional boolean )
Whether or not the SHIFT key is pressed.

InputContext

( object )
Describes an input Context
contextID
( integer )
This is used to specify targets of text field operations. This ID becomes invalid as soon as onBlur is called.
type
( enumerated string ["text", "number", "password"] )
Type of value this text field edits, (Text, Number, Password, etc)