Class TextKeyListener

java.lang.Object
icyllis.modernui.text.method.TextKeyListener

@ParametersAreNonnullByDefault public final class TextKeyListener extends Object
Provides methods for handling text additions and deletions in a TextView.
  • Method Details

    • getInstance

      public static TextKeyListener getInstance()
    • resetMetaState

      public static void resetMetaState(Spannable text)
      Resets all meta state to inactive.
    • getMetaState

      public static int getMetaState(CharSequence text, int meta)
      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

      public 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.
    • onKeyDown

      public boolean onKeyDown(TextView view, Editable content, int keyCode, KeyEvent event)
      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

      public boolean onKeyUp(TextView view, Editable content, int keyCode, KeyEvent event)
      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

      public boolean backspace(TextView view, Editable content, KeyEvent event)
      Performs the action that happens when you press the KeyEvent.KEY_BACKSPACE key in a TextView. 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

      public boolean forwardDelete(TextView view, Editable content, KeyEvent event)
      Performs the action that happens when you press the KeyEvent.KEY_DELETE key in a TextView. 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.