Package icyllis.modernui.text.method
Class TextKeyListener
java.lang.Object
icyllis.modernui.text.method.TextKeyListener
Provides methods for handling text additions and deletions in a
TextView
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
Performs the action that happens when you press theKeyEvent.KEY_BACKSPACE
key in aTextView
.boolean
forwardDelete
(TextView view, Editable content, KeyEvent event) Performs the action that happens when you press theKeyEvent.KEY_DELETE
key in aTextView
.static TextKeyListener
static int
getMetaState
(CharSequence text, int meta) Gets the state of a particular meta key.static boolean
isMetaTracker
(Object what) Returns true if this object is one that this class would use to keep track of any meta state in the specified text.boolean
If the key listener wants to handle this key, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.boolean
If the key listener wants to handle this key release, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.static void
resetMetaState
(Spannable text) Resets all meta state to inactive.
-
Method Details
-
getInstance
-
resetMetaState
Resets all meta state to inactive. -
getMetaState
Gets the state of a particular meta key.- Parameters:
text
- the buffer in which the meta key would have been pressed.meta
- META_SHIFT_ON, META_ALT_ON, META_SYM_ON- Returns:
- 0 if inactive, 1 if active, 2 if locked.
-
isMetaTracker
Returns true if this object is one that this class would use to keep track of any meta state in the specified text. -
onKeyDown
If the key listener wants to handle this key, return true, otherwise return false and the caller (i.e. the widget host) will handle the key. -
onKeyUp
If the key listener wants to handle this key release, return true, otherwise return false and the caller (i.e. the widget host) will handle the key. -
backspace
Performs the action that happens when you press theKeyEvent.KEY_BACKSPACE
key in aTextView
. If there is a selection, deletes the selection; otherwise, deletes the character before the cursor, if any; ALT+DEL deletes everything on the line the cursor is on.- Returns:
- true if anything was deleted; false otherwise.
-
forwardDelete
Performs the action that happens when you press theKeyEvent.KEY_DELETE
key in aTextView
. If there is a selection, deletes the selection; otherwise, deletes the character before the cursor, if any; ALT+FORWARD_DEL deletes everything on the line the cursor is on.- Returns:
- true if anything was deleted; false otherwise.
-