|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.ambient.views.KeyEventHandler
public class KeyEventHandler
Handles key events. onKey(int, int, KeyEvent) is invoked on
KeyEvent.Callback.onKeyDown(int, KeyEvent) and
KeyEvent.Callback.onKeyMultiple(int, int, KeyEvent). If key-down event is
suppressed, the key-up event is suppressed as well.
| Field Summary | |
|---|---|
protected java.util.Map<java.lang.Integer,java.lang.Boolean> |
keyDownHandled
Map of currently pressed buttons. |
| Constructor Summary | |
|---|---|
protected |
KeyEventHandler()
Creates new handler. |
| Method Summary | |
|---|---|
static android.view.KeyEvent.Callback |
compose(android.view.KeyEvent.Callback... keyCallbacks)
Composes multiple prioritized callbacks. |
boolean |
isConfirm(int keyCode)
Checks if given key code is the Center/Enter key. |
protected void |
keyUp(int keyCode,
android.view.KeyEvent event)
Handles the key-up event. |
static boolean |
moveFocus(android.view.View view,
boolean up)
Moves focus to next view. |
protected boolean |
onConfirm()
Invoked on center or
KeyEvent.KEYCODE_ENTER key press. |
protected boolean |
onDown()
Invoked on down arrow key press. |
protected boolean |
onKey(int keyCode,
int count,
android.view.KeyEvent event)
Invoked on key press. |
boolean |
onKey(android.view.KeyEvent event)
Handles a generic key event. |
boolean |
onKeyDown(int keyCode,
android.view.KeyEvent event)
|
boolean |
onKeyMultiple(int keyCode,
int count,
android.view.KeyEvent event)
|
boolean |
onKeyUp(int keyCode,
android.view.KeyEvent event)
|
protected boolean |
onLeft()
Invoked on left arrow key press. |
protected boolean |
onRight()
Invoked on right arrow key press. |
protected boolean |
onUp()
Invoked on up arrow key press. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final java.util.Map<java.lang.Integer,java.lang.Boolean> keyDownHandled
true
then the KeyEvent.Callback.onKeyDown(int, KeyEvent) was handled by this
handler and the KeyEvent.Callback.onKeyUp(int, KeyEvent) must be
suppressed.
| Constructor Detail |
|---|
protected KeyEventHandler()
| Method Detail |
|---|
public static boolean moveFocus(android.view.View view,
boolean up)
view - the current view.up - moves the focus up if true, moves the focus down
otherwise.
true if the focus was moved
protected boolean onKey(int keyCode,
int count,
android.view.KeyEvent event)
onUp, onDown... event handlers.
keyCode - the key codecount - the key repeat count. 0 is the first key pressevent - the event
true if the event was handled and is to be
suppressed, false otherwise.
protected void keyUp(int keyCode,
android.view.KeyEvent event)
keyCode - the key codeevent - the eventprotected boolean onUp()
up arrow key press.
true if the event was handled and is to be
suppressed, false otherwise.protected boolean onDown()
down arrow key press.
true if the event was handled and is to be
suppressed, false otherwise.protected boolean onLeft()
left arrow key press.
true if the event was handled and is to be
suppressed, false otherwise.protected boolean onRight()
right arrow key press.
true if the event was handled and is to be
suppressed, false otherwise.protected boolean onConfirm()
center or
KeyEvent.KEYCODE_ENTER key press.
true if the event was handled and is to be
suppressed, false otherwise.
public final boolean onKeyDown(int keyCode,
android.view.KeyEvent event)
onKeyDown in interface android.view.KeyEvent.Callback
public final boolean onKeyMultiple(int keyCode,
int count,
android.view.KeyEvent event)
onKeyMultiple in interface android.view.KeyEvent.Callbackpublic boolean isConfirm(int keyCode)
keyCode - the key code to check.
true on Center/Enter key, false
otherwise.
public final boolean onKeyUp(int keyCode,
android.view.KeyEvent event)
onKeyUp in interface android.view.KeyEvent.Callbackpublic final boolean onKey(android.view.KeyEvent event)
event - the event to handle
true if the event was consumed, false
otherwise.public static android.view.KeyEvent.Callback compose(android.view.KeyEvent.Callback... keyCallbacks)
keyCallbacks - a list of key callbacks. Must not be null nor
empty.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||