DispatcherState
open class DispatcherState
kotlin.Any | |
↳ | android.view.KeyEvent.DispatcherState |
Use with KeyEvent.dispatch(Callback, DispatcherState, Object)
for more advanced key dispatching, such as long presses.
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
open Unit |
handleUpEvent(event: KeyEvent!) Handle key up event to stop tracking. |
open Boolean |
isTracking(event: KeyEvent!) Return true if the key event is for a key code that is currently being tracked by the dispatcher. |
open Unit |
performedLongPress(event: KeyEvent!) Keep track of the given event's key code as having performed an action with a long press, so no action should occur on the up. |
open Unit |
reset() Reset back to initial state. |
open Unit |
Stop any tracking associated with this target. |
open Unit |
startTracking(event: KeyEvent!, target: Any!) Start tracking the key code associated with the given event. |
Public constructors
DispatcherState
DispatcherState()
Public methods
handleUpEvent
open fun handleUpEvent(event: KeyEvent!): Unit
Handle key up event to stop tracking. This resets the dispatcher state, and updates the key event state based on it.
This is only needed if you are directly dispatching events, rather than handling them in Callback.onKeyUp
.
isTracking
open fun isTracking(event: KeyEvent!): Boolean
Return true if the key event is for a key code that is currently being tracked by the dispatcher.
performedLongPress
open fun performedLongPress(event: KeyEvent!): Unit
Keep track of the given event's key code as having performed an action with a long press, so no action should occur on the up.
This is only needed if you are directly dispatching events, rather than handling them in Callback.onKeyLongPress
.
reset
open fun reset(target: Any!): Unit
Stop any tracking associated with this target.
startTracking
open fun startTracking(
event: KeyEvent!,
target: Any!
): Unit
Start tracking the key code associated with the given event. This can only be called on a key down. It will allow you to see any long press associated with the key, and will result in KeyEvent.isTracking
return true on the long press and up events.
This is only needed if you are directly dispatching events, rather than handling them in Callback.onKeyDown
.