Package org.mozilla.geckoview
Class SessionTextInput
Object
org.mozilla.geckoview.SessionTextInput
SessionTextInput
handles text input for GeckoSession
through key events or input
methods. It is typically used to implement certain methods in View
such as
View.onCreateInputConnection(android.view.inputmethod.EditorInfo)
, by forwarding such calls to corresponding
methods in SessionTextInput
.
For full functionality, SessionTextInput
requires a View
to be
set first through setView(android.view.View)
. When a View
is not set or set to null,
SessionTextInput
will operate in a reduced functionality mode. See onCreateInputConnection(android.view.inputmethod.EditorInfo)
and methods in GeckoSession.TextInputDelegate
for changes in
behavior in this viewless mode.
-
Method Summary
Modifier and TypeMethodDescriptionGet the current text input delegate.getHandler
(Handler defHandler) Get a Handler for the background input method thread.getView()
Get the currentView
for text input.Get anInputConnection
instance.boolean
Process a KeyEvent as a key-down event.boolean
onKeyLongPress
(int keyCode, KeyEvent event) Process a KeyEvent as a long-press event.boolean
onKeyMultiple
(int keyCode, int repeatCount, KeyEvent event) Process a KeyEvent as a multiple-press event.boolean
onKeyPreIme
(int keyCode, KeyEvent event) Process a KeyEvent as a pre-IME event.boolean
Process a KeyEvent as a key-up event.void
setDelegate
(GeckoSession.TextInputDelegate delegate) Set the current text input delegate.void
Set the currentView
for text input.
-
Method Details
-
getHandler
Get a Handler for the background input method thread. In order to use a background thread for input method operations on systems prior to Nougat, first overrideView.getHandler()
for the View returning the InputConnection instance, and then call this method from the overridden method.For example:
@Override public Handler getHandler() { if (Build.VERSION.SDK_INT >= 24) { return super.getHandler(); } return getSession().getTextInput().getHandler(super.getHandler()); }
- Parameters:
defHandler
- Handler returned by the systemgetHandler
implementation.- Returns:
- Handler to return to the system through
getHandler
.
-
getView
Get the currentView
for text input.- Returns:
- Current text input View or null if not set.
- See Also:
-
setView
Set the currentView
for text input. TheView
is used to interact with the system input method manager and to display certain text input UI elements. See theSessionTextInput
class documentation for information on viewless mode, when the currentView
is not set or set to null.- Parameters:
view
- Text input View or null to clear current View.- See Also:
-
onCreateInputConnection
Get anInputConnection
instance. In viewless mode, this method still fills out theEditorInfo
object, but the return value will always be null.- Parameters:
attrs
- EditorInfo instance to be filled on return.- Returns:
- InputConnection instance, or null if there is no active input (or if in viewless mode).
-
onKeyPreIme
Process a KeyEvent as a pre-IME event.- Parameters:
keyCode
- Key code.event
- KeyEvent instance.- Returns:
- True if the event was handled.
-
onKeyDown
Process a KeyEvent as a key-down event.- Parameters:
keyCode
- Key code.event
- KeyEvent instance.- Returns:
- True if the event was handled.
-
onKeyUp
Process a KeyEvent as a key-up event.- Parameters:
keyCode
- Key code.event
- KeyEvent instance.- Returns:
- True if the event was handled.
-
onKeyLongPress
Process a KeyEvent as a long-press event.- Parameters:
keyCode
- Key code.event
- KeyEvent instance.- Returns:
- True if the event was handled.
-
onKeyMultiple
Process a KeyEvent as a multiple-press event.- Parameters:
keyCode
- Key code.repeatCount
- Key repeat count.event
- KeyEvent instance.- Returns:
- True if the event was handled.
-
setDelegate
Set the current text input delegate.- Parameters:
delegate
- TextInputDelegate instance or null to restore to default.
-
getDelegate
Get the current text input delegate.- Returns:
- TextInputDelegate instance or a default instance if no delegate has been set.
-