List of usage examples for android.view KeyEvent META_SHIFT_ON
int META_SHIFT_ON
To view the source code for android.view KeyEvent META_SHIFT_ON.
Click Source Link
This mask is used to check whether one of the SHIFT meta keys is pressed.
From source file:org.connectbot.util.TerminalTextViewOverlay.java
@Override @TargetApi(12)/*from w w w . ja v a 2 s. c o m*/ public boolean onGenericMotionEvent(MotionEvent event) { if ((MotionEventCompat.getSource(event) & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: // Process scroll wheel movement: float yDistance = MotionEventCompat.getAxisValue(event, MotionEvent.AXIS_VSCROLL); vt320 vtBuffer = (vt320) terminalView.bridge.buffer; boolean mouseReport = vtBuffer.isMouseReportEnabled(); if (mouseReport) { int row = (int) Math.floor(event.getY() / terminalView.bridge.charHeight); int col = (int) Math.floor(event.getX() / terminalView.bridge.charWidth); vtBuffer.mouseWheel(yDistance > 0, col, row, (event.getMetaState() & KeyEvent.META_CTRL_ON) != 0, (event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0, (event.getMetaState() & KeyEvent.META_META_ON) != 0); return true; } } } return super.onGenericMotionEvent(event); }
From source file:com.volosyukivan.WiFiInputMethod.java
void resetModifiers() { InputConnection conn = getCurrentInputConnection(); if (conn == null) { return;/* www. jav a2 s . c o m*/ } conn.clearMetaKeyStates(KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON); }
From source file:org.connectbot.util.TerminalTextViewOverlay.java
/** * @param event//from ww w .ja v a 2 s.com * @param bridge * @return True if the event is handled. */ @TargetApi(14) private boolean onMouseEvent(MotionEvent event, TerminalBridge bridge) { int row = (int) Math.floor(event.getY() / bridge.charHeight); int col = (int) Math.floor(event.getX() / bridge.charWidth); int meta = event.getMetaState(); boolean shiftOn = (meta & KeyEvent.META_SHIFT_ON) != 0; vt320 vtBuffer = (vt320) bridge.buffer; boolean mouseReport = vtBuffer.isMouseReportEnabled(); // MouseReport can be "defeated" using the shift key. if (!mouseReport || shiftOn) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getButtonState() == MotionEvent.BUTTON_TERTIARY) { // Middle click pastes. pasteClipboard(); return true; } // Begin "selection mode" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { closeSelectionActionMode(); } } else if (event.getAction() == MotionEvent.ACTION_MOVE) { // In the middle of selection. if (selectionActionMode == null) { selectionActionMode = startActionMode(new TextSelectionActionModeCallback()); } int selectionStart = getSelectionStart(); int selectionEnd = getSelectionEnd(); if (selectionStart > selectionEnd) { int tempStart = selectionStart; selectionStart = selectionEnd; selectionEnd = tempStart; } currentSelection = getText().toString().substring(selectionStart, selectionEnd); } } else if (event.getAction() == MotionEvent.ACTION_DOWN) { terminalView.viewPager.setPagingEnabled(false); vtBuffer.mousePressed(col, row, mouseEventToJavaModifiers(event)); return true; } else if (event.getAction() == MotionEvent.ACTION_UP) { terminalView.viewPager.setPagingEnabled(true); vtBuffer.mouseReleased(col, row); return true; } else if (event.getAction() == MotionEvent.ACTION_MOVE) { int buttonState = event.getButtonState(); int button = (buttonState & MotionEvent.BUTTON_PRIMARY) != 0 ? 0 : (buttonState & MotionEvent.BUTTON_SECONDARY) != 0 ? 1 : (buttonState & MotionEvent.BUTTON_TERTIARY) != 0 ? 2 : 3; vtBuffer.mouseMoved(button, col, row, (meta & KeyEvent.META_CTRL_ON) != 0, (meta & KeyEvent.META_SHIFT_ON) != 0, (meta & KeyEvent.META_META_ON) != 0); return true; } return false; }
From source file:com.volosyukivan.WiFiInputMethod.java
void sendKey(int code, boolean down, boolean resetModifiers) { long time = System.currentTimeMillis(); if (time - lastWake > 5000) { wakeLock.acquire();/*from w ww. j av a 2 s. c om*/ wakeLock.release(); lastWake = time; } InputConnection conn = getCurrentInputConnection(); if (conn == null) { // Debug.d("connection closed"); return; } if (code < 0) { if (down == false) return; switch (code) { case KEY_HOME: keyHome(conn); break; case KEY_END: keyEnd(conn); break; case KEY_DEL: keyDel(conn); break; } return; } if (code == KeyEvent.KEYCODE_DPAD_LEFT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordLeft(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_RIGHT && pressedKeys.contains(KEY_CONTROL)) { if (down == false) return; wordRight(conn); return; } else if (code == KeyEvent.KEYCODE_DPAD_CENTER) { if (pressedKeys.contains(KEY_CONTROL)) { if (!down) return; copy(conn); return; } if (pressedKeys.contains(KeyEvent.KEYCODE_SHIFT_LEFT)) { if (!down) return; paste(conn); return; } } // if (pressedKeys.contains(KEY_CONTROL)) { // if (down == false) return; // switch (code) { // case KeyEvent.KEYCODE_A: selectAll(conn); break; // case KeyEvent.KEYCODE_X: cut(conn); break; // case KeyEvent.KEYCODE_C: copy(conn); break; // case KeyEvent.KEYCODE_V: paste(conn); break; // } // return; // } conn.sendKeyEvent(new KeyEvent(down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP, code)); if (resetModifiers) { conn.clearMetaKeyStates(KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON); } }
From source file:org.connectbot.util.TerminalTextViewOverlay.java
/** * Takes an android mouse event and produces a Java InputEvent modifiers int which can be * passed to vt320.// w w w .j a v a2 s. c om * @param mouseEvent The {@link MotionEvent} which should be a mouse click or release. * @return A Java InputEvent modifier int. See * http://docs.oracle.com/javase/7/docs/api/java/awt/event/InputEvent.html */ @TargetApi(14) private static int mouseEventToJavaModifiers(MotionEvent mouseEvent) { if (MotionEventCompat.getSource(mouseEvent) != InputDevice.SOURCE_MOUSE) return 0; int mods = 0; // See http://docs.oracle.com/javase/7/docs/api/constant-values.html int buttonState = mouseEvent.getButtonState(); if ((buttonState & MotionEvent.BUTTON_PRIMARY) != 0) mods |= 16; if ((buttonState & MotionEvent.BUTTON_SECONDARY) != 0) mods |= 8; if ((buttonState & MotionEvent.BUTTON_TERTIARY) != 0) mods |= 4; // Note: Meta and Ctrl are intentionally swapped here to keep logic in vt320 simple. int meta = mouseEvent.getMetaState(); if ((meta & KeyEvent.META_META_ON) != 0) mods |= 2; if ((meta & KeyEvent.META_SHIFT_ON) != 0) mods |= 1; if ((meta & KeyEvent.META_CTRL_ON) != 0) mods |= 4; return mods; }
From source file:com.actionbarsherlock.internal.view.menu.MenuBuilder.java
@SuppressWarnings("deprecation") void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) { final boolean qwerty = isQwertyMode(); final int metaState = event.getMetaState(); final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); // Get the chars associated with the keyCode (i.e using any chording combo) final boolean isKeyCodeMapped = event.getKeyData(possibleChars); // The delete key is not mapped to '\b' so we treat it specially if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) { return;//from w ww . j a v a 2 s.c o m } // Look for an item whose shortcut is this key. final int N = mItems.size(); for (int i = 0; i < N; i++) { MenuItemImpl item = mItems.get(i); if (item.hasSubMenu()) { ((MenuBuilder) item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event); } final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut(); if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) && (shortcutChar != 0) && (shortcutChar == possibleChars.meta[0] || shortcutChar == possibleChars.meta[2] || (qwerty && shortcutChar == '\b' && keyCode == KeyEvent.KEYCODE_DEL)) && item.isEnabled()) { items.add(item); } } }
From source file:androidv7.rmenu.MBuilder.java
@SuppressWarnings("deprecation") void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) { final boolean qwerty = isQwertyMode(); final int metaState = event.getMetaState(); final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData(); // Get the chars associated with the keyCode (i.e using any chording combo) final boolean isKeyCodeMapped = event.getKeyData(possibleChars); // The delete key is not mapped to '\b' so we treat it specially if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) { return;/* w ww .j a va 2s .c om*/ } // Look for an item whose shortcut is this key. final int N = mItems.size(); for (int i = 0; i < N; i++) { MenuItemImpl item = mItems.get(i); if (item.hasSubMenu()) { ((MBuilder) item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event); } final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut(); if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) && (shortcutChar != 0) && (shortcutChar == possibleChars.meta[0] || shortcutChar == possibleChars.meta[2] || (qwerty && shortcutChar == '\b' && keyCode == KeyEvent.KEYCODE_DEL)) && item.isEnabled()) { items.add(item); } } }
From source file:com.hippo.widget.BothScrollView.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { if (!mIsBeingDragged) { if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) { final float hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (hscroll != 0) { final int delta = (int) (hscroll * getHorizontalScrollFactor()); final int range = getHorizontalScrollRange(); int oldScrollX = getScrollX(); int newScrollX = oldScrollX + delta; if (newScrollX < 0) { newScrollX = 0; } else if (newScrollX > range) { newScrollX = range; }//from w w w . j av a2s .c om if (newScrollX != oldScrollX) { super.scrollTo(newScrollX, getScrollY()); return true; } } } else { final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (vscroll != 0) { final int delta = (int) (vscroll * getVerticalScrollFactor()); final int range = getVerticalScrollRange(); int oldScrollY = getScrollY(); int newScrollY = oldScrollY - delta; if (newScrollY < 0) { newScrollY = 0; } else if (newScrollY > range) { newScrollY = range; } if (newScrollY != oldScrollY) { super.scrollTo(getScrollX(), newScrollY); return true; } } } } } } } return super.onGenericMotionEvent(event); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { Logger.d(TAG, "onKeyUp keycode=%d", keyCode); switch (keyCode) { // Issue 248// w w w.ja v a2 s . c o m case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: if (!isInputViewShown()) { return super.onKeyUp(keyCode, event); } if (mAskPrefs.useVolumeKeyForLeftRight()) { // no need of vol up/down sound return true; } case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: if (getInputView() != null && getInputView().isShown() && getInputView().isShifted()) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON); InputConnection ic = getCurrentInputConnection(); if (ic != null) ic.sendKeyEvent(event); return true; } break; case KeyEvent.KEYCODE_ALT_LEFT: case KeyEvent.KEYCODE_ALT_RIGHT: case KeyEvent.KEYCODE_SHIFT_LEFT: case KeyEvent.KEYCODE_SHIFT_RIGHT: case KeyEvent.KEYCODE_SYM: mMetaState = MyMetaKeyKeyListener.handleKeyUp(mMetaState, keyCode, event); Logger.d(TAG + "-meta-key", getMetaKeysStates("onKeyUp")); setInputConnectionMetaStateAsCurrentMetaKeyKeyListenerState(); break; } return super.onKeyUp(keyCode, event); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
private void setInputConnectionMetaStateAsCurrentMetaKeyKeyListenerState() { InputConnection ic = getCurrentInputConnection(); if (ic != null) { int clearStatesFlags = 0; if (MyMetaKeyKeyListener.getMetaState(mMetaState, MyMetaKeyKeyListener.META_ALT_ON) == 0) clearStatesFlags += KeyEvent.META_ALT_ON; if (MyMetaKeyKeyListener.getMetaState(mMetaState, MyMetaKeyKeyListener.META_SHIFT_ON) == 0) clearStatesFlags += KeyEvent.META_SHIFT_ON; if (MyMetaKeyKeyListener.getMetaState(mMetaState, MyMetaKeyKeyListener.META_SYM_ON) == 0) clearStatesFlags += KeyEvent.META_SYM_ON; ic.clearMetaKeyStates(clearStatesFlags); }// w w w . j a v a2s. c o m }