Java Code Examples for android.view.KeyEvent#KEYCODE_DPAD_LEFT
The following examples show how to use
android.view.KeyEvent#KEYCODE_DPAD_LEFT .
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: VerticalViewPager.java From ticdesign with Apache License 2.0 | 6 votes |
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy. * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (event.hasNoModifiers()) { handled = arrowScroll(FOCUS_FORWARD); } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 2
Source File: RangeSeekBar.java From RangeSeekBar with MIT License | 6 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (isEnabled()) { int increment = mKeyProgressIncrement; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_MINUS: increment = -increment; // fallthrough case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_PLUS: case KeyEvent.KEYCODE_EQUALS: if (setProgressInternal(getProgressStart() - increment, getProgressEnd() + increment, true, true)) { onKeyChange(); return true; } break; } } return super.onKeyDown(keyCode, event); }
Example 3
Source File: DocumentView.java From Mupdf with Apache License 2.0 | 6 votes |
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_RIGHT: lineByLineMoveTo(1); return true; case KeyEvent.KEYCODE_DPAD_LEFT: lineByLineMoveTo(-1); return true; case KeyEvent.KEYCODE_DPAD_DOWN: verticalDpadScroll(1); return true; case KeyEvent.KEYCODE_DPAD_UP: verticalDpadScroll(-1); return true; } } return super.dispatchKeyEvent(event); }
Example 4
Source File: ViewPager.java From guideshow with MIT License | 6 votes |
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy. * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 5
Source File: ViewPagerEx.java From ImageSliderWithSwipes with Apache License 2.0 | 6 votes |
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy. * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 6
Source File: VerticalViewPager.java From actor-platform with GNU Affero General Public License v3.0 | 6 votes |
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy. * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 7
Source File: ViewPager.java From android-recipes-app with Apache License 2.0 | 6 votes |
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy. * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 8
Source File: FreeScrollingTextField.java From CodeEditor with Apache License 2.0 | 6 votes |
private void handleNavigationKey(int keyCode, KeyEvent event) { if (event.isShiftPressed() && !isSelectText()) { invalidateCaretRow(); _fieldController.setSelectText(true); } else if (!event.isShiftPressed() && isSelectText()) { invalidateSelectionRows(); _fieldController.setSelectText(false); } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_RIGHT: _fieldController.moveCaretRight(false); break; case KeyEvent.KEYCODE_DPAD_LEFT: _fieldController.moveCaretLeft(false); break; case KeyEvent.KEYCODE_DPAD_DOWN: _fieldController.moveCaretDown(); break; case KeyEvent.KEYCODE_DPAD_UP: _fieldController.moveCaretUp(); break; default: break; } }
Example 9
Source File: SkbContainer.java From Android-tv-widget with Apache License 2.0 | 6 votes |
/** * 处理UP的事件. */ @Override public boolean onSoftKeyUp(int keyCode, KeyEvent event) { if (!isFocused()) { return false; } OPENLOG.D("onSoftKeyUp keyCode:" + keyCode); if (mSoftKeyboardView != null) mSoftKeyboardView.setSoftKeyPress(false); switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_DPAD_LEFT: // 左 case KeyEvent.KEYCODE_DPAD_RIGHT: // 右 case KeyEvent.KEYCODE_DPAD_UP: // 上 case KeyEvent.KEYCODE_DPAD_DOWN: // 下 case KeyEvent.KEYCODE_BACK: OPENLOG.D("onSoftKeyUp true keyCode:" + keyCode); return true; } OPENLOG.D("onSoftKeyUp false keyCode:" + keyCode); return false; }
Example 10
Source File: ViewPager.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy. * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 11
Source File: UnicodeChart.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (mBase > 0) { mBase -= 1; invalidate(); } return true; case KeyEvent.KEYCODE_DPAD_RIGHT: mBase += 1; invalidate(); return true; default: break; } return super.onKeyDown(keyCode, event); }
Example 12
Source File: ViewPager.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * You can call this function yourself to have the scroll view perform * scrolling from a key event, just as if the event had been dispatched to * it by the view hierarchy. * * @param event The key event to execute. * @return Return true if the event was handled, else false. */ public boolean executeKeyEvent(KeyEvent event) { boolean handled = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = arrowScroll(FOCUS_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: if (Build.VERSION.SDK_INT >= 11) { // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD // before Android 3.0. Ignore the tab key on those devices. if (KeyEventCompat.hasNoModifiers(event)) { handled = arrowScroll(FOCUS_FORWARD); } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { handled = arrowScroll(FOCUS_BACKWARD); } } break; } } return handled; }
Example 13
Source File: DiscreteSeekBar.java From FuAgoraDemoDroid with MIT License | 6 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { //TODO: Should we reverse the keys for RTL? The framework's SeekBar does NOT.... boolean handled = false; if (isEnabled()) { int progress = getAnimatedProgress(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = true; if (progress <= mMin) break; animateSetProgress(progress - mKeyProgressIncrement); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = true; if (progress >= mMax) break; animateSetProgress(progress + mKeyProgressIncrement); break; } } return handled || super.onKeyDown(keyCode, event); }
Example 14
Source File: KeysInterpreter.java From CodeEditor with Apache License 2.0 | 5 votes |
public static boolean isNavigationKey(KeyEvent event) { int keyCode = event.getKeyCode(); return keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT; }
Example 15
Source File: GameControllerInput.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
private static boolean isGameKey(int keyCode) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_SPACE: return true; default: return KeyEvent.isGamepadButton(keyCode); } }
Example 16
Source File: BaseSlider.java From material-components-android with Apache License 2.0 | 5 votes |
private Boolean onKeyDownNoActiveThumb(int keyCode, @NonNull KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_TAB: if (event.hasNoModifiers()) { return moveFocus(1); } if (event.isShiftPressed()) { return moveFocus(-1); } return false; case KeyEvent.KEYCODE_DPAD_LEFT: moveFocusInAbsoluteDirection(-1); return true; case KeyEvent.KEYCODE_MINUS: moveFocus(-1); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: moveFocusInAbsoluteDirection(1); return true; case KeyEvent.KEYCODE_EQUALS: // Numpad Plus == Shift + Equals, at least in AVD, so fall through. case KeyEvent.KEYCODE_PLUS: moveFocus(1); return true; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: activeThumbIdx = focusedThumbIdx; postInvalidate(); return true; default: // Nothing to do in this case. } return null; }
Example 17
Source File: SlideOnePageGallery.java From mobile-manager-tool with MIT License | 5 votes |
@Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { int kEvent; if (isScrollingLeft(e1, e2)) { // Check if scrolling left kEvent = KeyEvent.KEYCODE_DPAD_LEFT; } else { // Otherwise scrolling right kEvent = KeyEvent.KEYCODE_DPAD_RIGHT; } onKeyDown(kEvent, null); return true; }
Example 18
Source File: KeyAssignmentUtils.java From talkback with Apache License 2.0 | 5 votes |
public static boolean isKeyCodeToIgnore(Context context, int keyCode) { // If we're not on Android TV, don't ignore any keys. UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE); if ((uiModeManager == null) || (uiModeManager.getCurrentModeType() != Configuration.UI_MODE_TYPE_TELEVISION)) { return false; } return ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER) || (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) || (keyCode == KeyEvent.KEYCODE_DPAD_UP) || (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) || (keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_DPAD_LEFT)); }
Example 19
Source File: XulRenderContext.java From starcor.xul with GNU Lesser General Public License v3.0 | 4 votes |
public boolean onKeyEvent(KeyEvent event) { XulLayout layout; if (_page == null || (layout = _page.getLayout()) == null) { lastKeyAction = -1; lastKeyCode = -1; lastKeyEventView = null; lastDownHandled = false; return false; } int keyAction = event.getAction(); int keyCode = event.getKeyCode(); XulView focusView = layout.getFocus(); boolean ret = false; if (keyAction == KeyEvent.ACTION_DOWN) { if (layout.onKeyEvent(event)) { lastKeyAction = keyAction; lastKeyCode = keyCode; lastKeyEventView = getWeakReference(focusView); ret = true; } else switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_LEFT); break; case KeyEvent.KEYCODE_DPAD_RIGHT: ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_RIGHT); break; case KeyEvent.KEYCODE_DPAD_UP: ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_UP); break; case KeyEvent.KEYCODE_DPAD_DOWN: ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_DOWN); break; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: ret = layout.doClick(actionCallback); break; case KeyEvent.KEYCODE_BACK: ret = _page.popStates(); if (ret) { XulPage.invokeActionNoPopup(_page, "statesRestored"); } break; } lastDownHandled = ret; } else if (keyAction == KeyEvent.ACTION_UP) { XulView xulView = lastKeyEventView == null ? null : lastKeyEventView.get(); if (xulView != focusView) { ret = lastDownHandled; } else if (layout.onKeyEvent(event)) { lastKeyAction = keyAction; lastKeyCode = keyCode; lastKeyEventView = getWeakReference(focusView); ret = true; } else switch (keyCode) { default: ret = lastDownHandled; break; } lastDownHandled = false; } lastKeyAction = keyAction; lastKeyCode = keyCode; lastKeyEventView = getWeakReference(focusView); if (ret) { suspendDrawableWorker(); } return ret; }
Example 20
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; } } }