public class QwertyKeyListener extends BaseKeyListener
KeyListener
, this class is only concerned
with hardware keyboards. Software input methods have no obligation to trigger
the methods in this class.META_ALT_LOCKED, META_ALT_ON, META_CAP_LOCKED, META_SELECTING, META_SHIFT_ON, META_SYM_LOCKED, META_SYM_ON
Constructor and Description |
---|
QwertyKeyListener(TextKeyListener.Capitalize cap,
boolean autoText) |
Modifier and Type | Method and Description |
---|---|
int |
getInputType()
Return the type of text that this key listener is manipulating,
as per
InputType . |
static QwertyKeyListener |
getInstance(boolean autoText,
TextKeyListener.Capitalize cap)
Returns a new or existing instance with the specified capitalization
and correction properties.
|
static QwertyKeyListener |
getInstanceForFullKeyboard()
Gets an instance of the listener suitable for use with full keyboards.
|
static void |
markAsReplaced(Spannable content,
int start,
int end,
String original)
Marks the specified region of
content as having
contained original prior to AutoText replacement. |
boolean |
onKeyDown(View view,
Editable content,
int keyCode,
KeyEvent event)
Handles presses of the meta keys.
|
backspace, forwardDelete, onKeyOther
adjustMetaAfterKeypress, adjustMetaAfterKeypress, clearMetaKeyState, clearMetaKeyState, clearMetaKeyState, getMetaState, getMetaState, getMetaState, getMetaState, getMetaState, getMetaState, handleKeyDown, handleKeyUp, isMetaTracker, isSelectingMetaTracker, onKeyUp, resetLockedMeta, resetLockedMeta, resetMetaState, startSelecting, stopSelecting
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearMetaKeyState, onKeyUp
public QwertyKeyListener(TextKeyListener.Capitalize cap, boolean autoText)
public static QwertyKeyListener getInstance(boolean autoText, TextKeyListener.Capitalize cap)
public static QwertyKeyListener getInstanceForFullKeyboard()
public int getInputType()
KeyListener
InputType
. This is used to
determine the mode of the soft keyboard that is shown for the editor.
If you return
InputType.TYPE_NULL
then no soft keyboard will provided. In other words, you
must be providing your own key pad for on-screen input and the key
listener will be used to handle input from a hard keyboard.
If you return any other value, a soft input method will be created when the user puts focus in the editor, which will provide a keypad and also consume hard key events. This means that the key listener will generally not be used, instead the soft input method will take care of managing key input as per the content type returned here.
public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event)
MetaKeyKeyListener
onKeyDown
in interface KeyListener
onKeyDown
in class BaseKeyListener
public static void markAsReplaced(Spannable content, int start, int end, String original)
content
as having
contained original
prior to AutoText replacement.
Call this method when you have done or are about to do an
AutoText-style replacement on a region of text and want to let
the same mechanism (the user pressing DEL immediately after the
change) undo the replacement.content
- the Editable text where the replacement was madestart
- the start of the replaced regionend
- the end of the replaced region; the location of the cursororiginal
- the text to be restored if the user presses DEL