Java Code Examples for android.view.KeyEvent#KEYCODE_MOVE_HOME
The following examples show how to use
android.view.KeyEvent#KEYCODE_MOVE_HOME .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FocusHelper.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
/** * Helper method to be used for playing sound effects. */ @Thunk private static void playSoundEffect(int keyCode, View v) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT); break; case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_PAGE_DOWN: case KeyEvent.KEYCODE_MOVE_END: v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN); break; case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_PAGE_UP: case KeyEvent.KEYCODE_MOVE_HOME: v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP); break; default: break; } }
Example 2
Source File: FocusHelper.java From Trebuchet with GNU General Public License v3.0 | 6 votes |
/** * Helper method to be used for playing sound effects. */ @Thunk static void playSoundEffect(int keyCode, View v) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: v.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT); break; case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_PAGE_DOWN: case KeyEvent.KEYCODE_MOVE_END: v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN); break; case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_PAGE_UP: case KeyEvent.KEYCODE_MOVE_HOME: v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP); break; default: break; } }
Example 3
Source File: FreeScrollingTextField.java From CodeEditor with Apache License 2.0 | 5 votes |
@Override public boolean sendKeyEvent(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_SHIFT_LEFT: if (isSelectText()) selectText(false); else selectText(true); break; case KeyEvent.KEYCODE_DPAD_LEFT: moveCaretLeft(); break; case KeyEvent.KEYCODE_DPAD_UP: moveCaretUp(); break; case KeyEvent.KEYCODE_DPAD_RIGHT: moveCaretRight(); break; case KeyEvent.KEYCODE_DPAD_DOWN: moveCaretDown(); break; case KeyEvent.KEYCODE_MOVE_HOME: moveCaret(0); break; case KeyEvent.KEYCODE_MOVE_END: moveCaret(_hDoc.length()); break; default: return super.sendKeyEvent(event); } return true; }
Example 4
Source File: FreeScrollingTextField.java From CodeEditor with Apache License 2.0 | 5 votes |
@Override public boolean sendKeyEvent(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_SHIFT_LEFT: if (isSelectText()) selectText(false); else selectText(true); break; case KeyEvent.KEYCODE_DPAD_LEFT: moveCaretLeft(); break; case KeyEvent.KEYCODE_DPAD_UP: moveCaretUp(); break; case KeyEvent.KEYCODE_DPAD_RIGHT: moveCaretRight(); break; case KeyEvent.KEYCODE_DPAD_DOWN: moveCaretDown(); break; case KeyEvent.KEYCODE_MOVE_HOME: moveCaret(0); break; case KeyEvent.KEYCODE_MOVE_END: moveCaret(_hDoc.length()); break; default: return super.sendKeyEvent(event); } return true; }
Example 5
Source File: FreeScrollingTextField.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public boolean sendKeyEvent(KeyEvent event) { if(event.getAction()==KeyEvent.ACTION_UP) return super.sendKeyEvent(event); switch (event.getKeyCode()) { case KeyEvent.KEYCODE_SHIFT_LEFT: case KeyEvent.KEYCODE_SHIFT_RIGHT: /*if (isSelectText()) selectText(false); else*/ selectText(true); break; case KeyEvent.KEYCODE_DPAD_LEFT: _fieldController.moveCaretLeft(true); break; case KeyEvent.KEYCODE_DPAD_UP: _fieldController.moveCaretUp(true); break; case KeyEvent.KEYCODE_DPAD_RIGHT: _fieldController.moveCaretRight(true); break; case KeyEvent.KEYCODE_DPAD_DOWN: _fieldController.moveCaretDown(true); break; case KeyEvent.KEYCODE_MOVE_HOME: moveCaret(0); break; case KeyEvent.KEYCODE_MOVE_END: moveCaret(_hDoc.length() - 1); break; default: return super.sendKeyEvent(event); } return true; }
Example 6
Source File: FocusLogic.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
/** * Returns true only if this utility class handles the key code. */ public static boolean shouldConsume(int keyCode) { return (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END || keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN); }
Example 7
Source File: FocusLogic.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
/** * Returns true only if this utility class handles the key code. */ public static boolean shouldConsume(int keyCode) { return (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END || keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN || keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL); }
Example 8
Source File: FastEdit.java From fastedit with Apache License 2.0 | 4 votes |
void onKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (action) { case KeyEvent.ACTION_DOWN: { //输入模式 int unicodeChar = event.getUnicodeChar(); if (unicodeChar != 0) { input((char) unicodeChar); event.cancel(); } if (!event.isCanceled() && !event.isCtrlPressed() && !event.isAltPressed() && !event.isShiftPressed()) { switch (keyCode) { case KeyEvent.KEYCODE_TAB: //tab input(tabText); event.cancel(); break; case KeyEvent.KEYCODE_SPACE: //空格 input(' '); event.cancel(); break; case KeyEvent.KEYCODE_ENTER: //enter onKeyCodeEnter(event); event.cancel(); break; case KeyEvent.KEYCODE_DEL: //del onKeyCodeDel(event); event.cancel(); break; case KeyEvent.KEYCODE_FORWARD_DEL: //del onKeyCodeForwardDel(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_LEFT: //left onKeyCodeDpadLeft(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_RIGHT: //right onKeyCodeDpadRight(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_UP: //up onKeyCodeDpadUp(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_DOWN: //down onKeyCodeDpadDown(event); event.cancel(); break; case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_PAGE_DOWN: //page down onKeyCodePageDown(event); event.cancel(); break; case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_PAGE_UP: //page up onKeyCodePageUp(event); event.cancel(); break; case KeyEvent.KEYCODE_MOVE_HOME: onKeyCodeMoveHome(event); event.cancel(); break; case KeyEvent.KEYCODE_MOVE_END: onKeyCodeMoveEnd(event); event.cancel(); break; } } if (!event.isCanceled()) { //快捷键模式 if (onShortKey(event.isCtrlPressed(), event.isAltPressed(), event.isShiftPressed(), keyCode)) { event.cancel(); } } break; } } }
Example 9
Source File: FastEdit.java From fastedit with Apache License 2.0 | 4 votes |
/** * 快捷方式 * * @param ctrl * @param alt * @param shift * @param keyCode */ protected boolean onShortKey(boolean ctrl, boolean alt, boolean shift, int keyCode) { if (ctrl) { if (keyCode == KeyEvent.KEYCODE_A) { selectModel.select(0, length()); postInvalidate(); return true; } if (keyCode == KeyEvent.KEYCODE_C) { if (selectModel.hasSelect()) { try { copy(); } catch (Exception e) { } return true; } } if (keyCode == KeyEvent.KEYCODE_X) { if (selectModel.hasSelect()) { cut(); return true; } } if (keyCode == KeyEvent.KEYCODE_Z) { undo(); return true; } if (keyCode == KeyEvent.KEYCODE_Y) { redo(); return true; } } if (shift) { try { if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { if (!selectModel.hasSelect()) { selectModel.start(cursorPos); } selectModel.toLeft(1); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { if (!selectModel.hasSelect()) { selectModel.start(cursorPos); } selectModel.toRight(1); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { if (!selectModel.hasSelect()) { selectModel.start(cursorPos); } selectModel.toUp(1); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { if (!selectModel.hasSelect()) { selectModel.start(cursorPos); } selectModel.toDown(1); return true; } else if (keyCode == KeyEvent.KEYCODE_MOVE_HOME) { if (!selectModel.hasSelect()) { selectModel.start(cursorPos); } selectModel.toHome(); return true; } else if (keyCode == KeyEvent.KEYCODE_MOVE_END) { if (!selectModel.hasSelect()) { selectModel.start(cursorPos); } selectModel.toEnd(); return true; } } finally { postInvalidate(); } } return false; }
Example 10
Source File: BaseMovementMethod.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Performs a movement key action. * The default implementation decodes the key down and invokes movement actions * such as {@link #down} and {@link #up}. * {@link #onKeyDown(TextView, Spannable, int, KeyEvent)} calls this method once * to handle an {@link KeyEvent#ACTION_DOWN}. * {@link #onKeyOther(TextView, Spannable, KeyEvent)} calls this method repeatedly * to handle each repetition of an {@link KeyEvent#ACTION_MULTIPLE}. * * @param widget The text view. * @param buffer The text buffer. * @param event The key event. * @param keyCode The key code. * @param movementMetaState The keyboard meta states used for movement. * @param event The key event. * @return True if the event was handled. */ protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return left(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return leftWord(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return lineStart(widget, buffer); } break; case KeyEvent.KEYCODE_DPAD_RIGHT: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return right(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return rightWord(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return lineEnd(widget, buffer); } break; case KeyEvent.KEYCODE_DPAD_UP: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return up(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return top(widget, buffer); } break; case KeyEvent.KEYCODE_DPAD_DOWN: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return down(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return bottom(widget, buffer); } break; case KeyEvent.KEYCODE_PAGE_UP: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return pageUp(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return top(widget, buffer); } break; case KeyEvent.KEYCODE_PAGE_DOWN: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return pageDown(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_ALT_ON)) { return bottom(widget, buffer); } break; case KeyEvent.KEYCODE_MOVE_HOME: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return home(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return top(widget, buffer); } break; case KeyEvent.KEYCODE_MOVE_END: if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) { return end(widget, buffer); } else if (KeyEvent.metaStateHasModifiers(movementMetaState, KeyEvent.META_CTRL_ON)) { return bottom(widget, buffer); } break; } return false; }
Example 11
Source File: FocusLogic.java From LaunchEnr with GNU General Public License v3.0 | 4 votes |
public static int handleKeyEvent(int keyCode, int [][] map, int iconIdx, int pageIndex, int pageCount, boolean isRtl) { int cntX = map == null ? -1 : map.length; int cntY = map == null ? -1 : map[0].length; int newIndex = NOOP; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, -1 /*increment*/, isRtl); if (!isRtl && newIndex == NOOP && pageIndex > 0) { newIndex = PREVIOUS_PAGE_RIGHT_COLUMN; } else if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) { newIndex = NEXT_PAGE_RIGHT_COLUMN; } break; case KeyEvent.KEYCODE_DPAD_RIGHT: newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, 1 /*increment*/, isRtl); if (!isRtl && newIndex == NOOP && pageIndex < pageCount - 1) { newIndex = NEXT_PAGE_LEFT_COLUMN; } else if (isRtl && newIndex == NOOP && pageIndex > 0) { newIndex = PREVIOUS_PAGE_LEFT_COLUMN; } break; case KeyEvent.KEYCODE_DPAD_DOWN: newIndex = handleDpadVertical(iconIdx, cntX, cntY, map, 1 /*increment*/); break; case KeyEvent.KEYCODE_DPAD_UP: newIndex = handleDpadVertical(iconIdx, cntX, cntY, map, -1 /*increment*/); break; case KeyEvent.KEYCODE_MOVE_HOME: newIndex = handleMoveHome(); break; case KeyEvent.KEYCODE_MOVE_END: newIndex = handleMoveEnd(); break; case KeyEvent.KEYCODE_PAGE_DOWN: newIndex = handlePageDown(pageIndex, pageCount); break; case KeyEvent.KEYCODE_PAGE_UP: newIndex = handlePageUp(pageIndex); break; default: break; } return newIndex; }
Example 12
Source File: FocusLogic.java From Trebuchet with GNU General Public License v3.0 | 4 votes |
public static int handleKeyEvent(int keyCode, int cntX, int cntY, int [][] map, int iconIdx, int pageIndex, int pageCount, boolean isRtl) { if (DEBUG) { Log.v(TAG, String.format( "handleKeyEvent START: cntX=%d, cntY=%d, iconIdx=%d, pageIdx=%d, pageCnt=%d", cntX, cntY, iconIdx, pageIndex, pageCount)); } int newIndex = NOOP; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, -1 /*increment*/); if (isRtl && newIndex == NOOP && pageIndex > 0) { newIndex = PREVIOUS_PAGE_RIGHT_COLUMN; } else if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) { newIndex = NEXT_PAGE_RIGHT_COLUMN; } break; case KeyEvent.KEYCODE_DPAD_RIGHT: newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, 1 /*increment*/); if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) { newIndex = NEXT_PAGE_LEFT_COLUMN; } else if (isRtl && newIndex == NOOP && pageIndex > 0) { newIndex = PREVIOUS_PAGE_LEFT_COLUMN; } break; case KeyEvent.KEYCODE_DPAD_DOWN: newIndex = handleDpadVertical(iconIdx, cntX, cntY, map, 1 /*increment*/); break; case KeyEvent.KEYCODE_DPAD_UP: newIndex = handleDpadVertical(iconIdx, cntX, cntY, map, -1 /*increment*/); break; case KeyEvent.KEYCODE_MOVE_HOME: newIndex = handleMoveHome(); break; case KeyEvent.KEYCODE_MOVE_END: newIndex = handleMoveEnd(); break; case KeyEvent.KEYCODE_PAGE_DOWN: newIndex = handlePageDown(pageIndex, pageCount); break; case KeyEvent.KEYCODE_PAGE_UP: newIndex = handlePageUp(pageIndex); break; default: break; } if (DEBUG) { Log.v(TAG, String.format("handleKeyEvent FINISH: index [%d -> %s]", iconIdx, getStringIndex(newIndex))); } return newIndex; }