List of usage examples for android.view KeyEvent getKeyCode
public final int getKeyCode()
From source file:self.philbrown.droidQuery.$.java
/** * Refreshes the listeners for key events */// ww w.ja va2 s.com private void setupKeyListener() { for (View view : views) { view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean retVal = false; switch (event.getKeyCode()) { case KeyEvent.ACTION_DOWN: { if (keyDown != null) { keyDown.invoke($.with(v), keyCode, event); retVal = true; } break; } case KeyEvent.ACTION_UP: { if (keyUp != null) { keyUp.invoke($.with(v), keyCode, event); retVal = true; } break; } } if (keyPress != null) { keyPress.invoke($.with(v), keyCode, event); retVal = true; } return retVal; } }); } }
From source file:vapor.view.VaporView.java
/** * Fluent equivalent Vapor method for invoking onKeyUp(int,KeyEvent), called * when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released. * /*from ww w . ja va 2s . c om*/ * @param keyEvent * The KeyEvent object that defines the button action. * @return If you handled the event, return true. If you want to allow the * event to be handled by the next receiver, return false. */ public boolean keyUp(KeyEvent keyEvent) { return view.onKeyUp(keyEvent.getKeyCode(), keyEvent); }
From source file:vapor.view.VaporView.java
/** * Fluent equivalent Vapor method for invoking onKeyDown(KeyEvent), called * when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released, if the view is * enabled and clickable.//from ww w. j a va 2 s . c o m * * @param keyEvent * The KeyEvent object that defines the button action. * @return If you handled the event, return true. If you want to allow the * event to be handled by the next receiver, return false. */ public boolean keyDown(KeyEvent keyEvent) { return view.onKeyDown(keyEvent.getKeyCode(), keyEvent); }
From source file:vapor.view.VaporView.java
/** * Fluent equivalent Vapor method for invoking onKeyPreIme(KeyEvent), used * to handle a key event before it is processed by any input method * associated with the view hierarchy./*w w w. j a v a 2 s. c o m*/ * * @param keyEvent * Description of the key event. * @return If you handled the event, return true. If you want to allow the * event to be handled by the next receiver, return false. */ public boolean keyPreIme(KeyEvent keyEvent) { return view.onKeyPreIme(keyEvent.getKeyCode(), keyEvent); }
From source file:vapor.view.VaporView.java
/** * Fluent equivalent Vapor method for invoking * onKeyMultiple(int,int,KeyEvent), always returns false (doesn't handle the * event).//from ww w. ja v a2s . com * * @param repeatCount * The number of times the action was made. * @param keyEvent * The KeyEvent object that defines the button action. * @return If you handled the event, return true. If you want to allow the * event to be handled by the next receiver, return false. */ public boolean keyMulti(int repeatCount, KeyEvent keyEvent) { return view.onKeyMultiple(keyEvent.getKeyCode(), repeatCount, keyEvent); }
From source file:vapor.view.VaporView.java
/** * Fluent equivalent Vapor method for invoking onKeyShortcut(KeyEvent), * called on the focused view when a key shortcut event is not handled. * /*from w w w.j a v a 2s . c o m*/ * @param keyEvent * Description of the key event. * @return If you handled the event, return true. If you want to allow the * event to be handled by the next receiver, return false. */ public boolean keyHot(KeyEvent keyEvent) { return view.onKeyShortcut(keyEvent.getKeyCode(), keyEvent); }
From source file:vapor.view.VaporView.java
/** * Fluent equivalent Vapor method for invoking onKeyLongPress(int,KeyEvent), * called always returns false (doesn't handle the event). * /* ww w . j a v a2 s. c o m*/ * @param keyEvent * Description of the key event. * @return If you handled the event, return true. If you want to allow the * event to be handled by the next receiver, return false. */ public boolean keyLongPress(KeyEvent keyEvent) { return view.onKeyLongPress(keyEvent.getKeyCode(), keyEvent); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: // 290661 commented this out to fix bug (Auto lock screen not popping up when back key is pressed from allapps screen) //TruMobiTimerClass.userInteractedStopTimer(); if (!allAppsOpen) { // android.os.Process.killProcess(android.os.Process.myPid()); mWorkspace.dispatchKeyEvent(event); finish();/*from w w w . j a v a 2 s .c o m*/ } mHandleView.updateIcon(); return true; case KeyEvent.KEYCODE_HOME: return true; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: if (!event.isCanceled()) { mWorkspace.dispatchKeyEvent(event); if (allAppsOpen) { closeDrawer(); } else { closeFolder(); } if (isPreviewing()) { dismissPreviews(); } if (mIsEditMode) { stopDesktopEdit(); } if (mIsWidgetEditMode) { stopWidgetEdit(); } } return true; case KeyEvent.KEYCODE_HOME: return true; } } return super.dispatchKeyEvent(event); }
From source file:android.app.Activity.java
/** * Called to process a key shortcut event. * You can override this to intercept all key shortcut events before they are * dispatched to the window. Be sure to call this implementation for key shortcut * events that should be handled normally. * * @param event The key shortcut event./*from w w w. j a v a 2 s . c om*/ * @return True if this event was consumed. */ public boolean dispatchKeyShortcutEvent(KeyEvent event) { onUserInteraction(); if (getWindow().superDispatchKeyShortcutEvent(event)) { return true; } return onKeyShortcut(event.getKeyCode(), event); }
From source file:com.bernard.beaconportal.activities.activity.MessageList.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { boolean ret = false; if (KeyEvent.ACTION_DOWN == event.getAction()) { ret = onCustomKeyDown(event.getKeyCode(), event); }/*from w w w . j a va2s. c o m*/ if (!ret) { ret = super.dispatchKeyEvent(event); } return ret; }