public interface InputMethodSession
InputMethod
that is safe to expose to applications.
Applications will not normally use this interface themselves, instead
relying on the standard interaction provided by
TextView
and EditText
.
Modifier and Type | Interface and Description |
---|---|
static interface |
InputMethodSession.EventCallback |
Modifier and Type | Method and Description |
---|---|
void |
appPrivateCommand(String action,
Bundle data)
Process a private command sent from the application to the input method.
|
void |
dispatchGenericMotionEvent(int seq,
MotionEvent event,
InputMethodSession.EventCallback callback)
This method is called when there is a generic motion event.
|
void |
dispatchKeyEvent(int seq,
KeyEvent event,
InputMethodSession.EventCallback callback)
This method is called when a key is pressed.
|
void |
dispatchTrackballEvent(int seq,
MotionEvent event,
InputMethodSession.EventCallback callback)
This method is called when there is a track ball event.
|
void |
displayCompletions(CompletionInfo[] completions)
Called by a text editor that performs auto completion, to tell the
input method about the completions it has available.
|
void |
finishInput()
This method is called when the application would like to stop
receiving text input.
|
void |
toggleSoftInput(int showFlags,
int hideFlags)
Toggle the soft input window.
|
void |
updateCursor(Rect newCursor)
This method is called when cursor location of the target input field
has changed within its window.
|
void |
updateExtractedText(int token,
ExtractedText text)
Called by a text editor to report its new extracted text when its
contents change.
|
void |
updateSelection(int oldSelStart,
int oldSelEnd,
int newSelStart,
int newSelEnd,
int candidatesStart,
int candidatesEnd)
This method is called when the selection or cursor in the current
target input field has changed.
|
void |
viewClicked(boolean focusChanged)
This method is called when the user tapped a text view.
|
void finishInput()
void updateSelection(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd)
oldSelStart
- The previous text offset of the cursor selection
start position.oldSelEnd
- The previous text offset of the cursor selection
end position.newSelStart
- The new text offset of the cursor selection
start position.newSelEnd
- The new text offset of the cursor selection
end position.candidatesStart
- The text offset of the current candidate
text start position.candidatesEnd
- The text offset of the current candidate
text end position.void viewClicked(boolean focusChanged)
focusChanged
- true if the user changed the focused view by this click.void updateCursor(Rect newCursor)
newCursor
- The rectangle of the cursor currently being shown in
the input field's window coordinates.void displayCompletions(CompletionInfo[] completions)
completions
- Array of text completions that are available, starting with
the best. If this array is null, any existing completions will be
removed.void updateExtractedText(int token, ExtractedText text)
InputConnection.getExtractedText()
with the option to report updates.token
- The input method supplied token for identifying its request.text
- The new extracted text.void dispatchKeyEvent(int seq, KeyEvent event, InputMethodSession.EventCallback callback)
If the input method wants to handle this event, return true, otherwise return false and the caller (i.e. the application) will handle the event.
event
- The key event.#dispatchKeyUp
,
KeyEvent
void dispatchTrackballEvent(int seq, MotionEvent event, InputMethodSession.EventCallback callback)
If the input method wants to handle this event, return true, otherwise return false and the caller (i.e. the application) will handle the event.
event
- The motion event.MotionEvent
void dispatchGenericMotionEvent(int seq, MotionEvent event, InputMethodSession.EventCallback callback)
If the input method wants to handle this event, return true, otherwise return false and the caller (i.e. the application) will handle the event.
event
- The motion event.MotionEvent
void appPrivateCommand(String action, Bundle data)
action
- Name of the command to be performed. This must
be a scoped name, i.e. prefixed with a package name you own, so that
different developers will not create conflicting commands.data
- Any data to include with the command.void toggleSoftInput(int showFlags, int hideFlags)
showFlags
- Provides additional operating flags. May be
0 or have the InputMethodManager.SHOW_IMPLICIT
,
InputMethodManager.SHOW_FORCED
bit set.hideFlags
- Provides additional operating flags. May be
0 or have the InputMethodManager.HIDE_IMPLICIT_ONLY
,
InputMethodManager.HIDE_NOT_ALWAYS
bit set.