public void keyPress(KeyEvent e) { // VK_ENTER: EnterKey, CTRL_DOWN_MASK: CtrlKey, META_DOWN_MASK: OS X's CommandKey if (e.getKeyCode() == KeyEvent.VK_ENTER) { if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) > 0 || (e.getModifiersEx() & InputEvent.META_DOWN_MASK) > 0) { tweet(); } } }
public void onKeyPressed(KeyEvent e) { int selectedIndex = list.getSelectedIndex(); int newIndex = selectedIndex; int rowsOnScreen = scroll.getHeight() / list.getFixedCellHeight(); switch (e.getKeyCode()) { case KeyEvent.VK_UP: case KeyEvent.VK_KP_UP: if (!e.isAltDown()) { newIndex--; } break; case KeyEvent.VK_DOWN: case KeyEvent.VK_KP_DOWN: if (!e.isAltDown()) { newIndex++; } break; case KeyEvent.VK_PAGE_UP: newIndex -= rowsOnScreen; break; case KeyEvent.VK_PAGE_DOWN: newIndex += rowsOnScreen; break; case KeyEvent.VK_ENTER: if ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) > 0) { model.suggest(field.getText().trim()); } else if ((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) > 0) { model.popOut(field.getText().trim()); } else { translateSelected(); } break; } // check, whether index was changed if (newIndex == selectedIndex) { return; } int size = list.getModel().getSize(); if (newIndex < 0) { newIndex = 0; } if (newIndex >= size) { newIndex = size - 1; } setSelectedIndex(newIndex); setSearchTextWithoutNavigating(getSelectedIndexText()); }
@Override public void keyPressed(Canvas canvas, KeyEvent e) { int code = e.getKeyCode(); if (active && (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL)) { updateMouse(canvas, lastMouseX, lastMouseY, e.getModifiersEx()); } }
public void keyReleased(KeyEvent e) { char c = e.getKeyChar(); // may be CHAR_UNDEFINED mouseButtonsAndModifierKeys = e.getModifiersEx(); if (c >= 0 && c < keyPressed.length) keyPressed[c] = false; int vk = e.getKeyCode(); if (vk >= 0 && vk < virtualKeyPressed.length) virtualKeyPressed[vk] = false; }
@Override public void keyPressed(KeyEvent e) { // if (e.getKeyCode() == KeyEvent.VK_TAB) { if (checkValidity()) { backup = getText(); if (e.getModifiersEx() == KeyEvent.SHIFT_DOWN_MASK) { index = index - 1; } else { index = index + 1; } if (index == capacity) { KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(); return; } if (index == -1) { KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(); return; } } else { setText(backup); Logger.getLogger(VectorTextField.class.getName()).log(Level.WARNING, "Invalid format"); } findSelection(0); } }
@Override public void keyReleased(KeyEvent evt) { multicaster.keyReleased(evt); // Forward key releases to the handler if (dragLocation != null) { multicaster.trackStep(anchor, dragLocation, evt.getModifiersEx(), getView()); } }
@Override public void keyReleased(Canvas canvas, KeyEvent e) { if (state == MOVING && e.getKeyCode() == KeyEvent.VK_SHIFT) { handleMoveDrag(canvas, curDx, curDy, e.getModifiersEx()); } else { processKeyEvent(canvas, e, KeyConfigurationEvent.KEY_RELEASED); } }
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode() | e.getModifiersEx(); if (keyCode == KeyEvent.VK_SPACE || keyCode == (KeyEvent.CTRL_DOWN_MASK | KeyEvent.VK_SPACE) || keyCode == (KeyEvent.META_DOWN_MASK | KeyEvent.VK_SPACE)) { this.doClick(); } }
public boolean globtype(char key, KeyEvent ev) { int c = ev.getKeyChar(); if ((key == 0) && (c >= KeyEvent.VK_1) && (c < KeyEvent.VK_1 + actions.length)) { int n = c - KeyEvent.VK_1; if ((ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) wdgmsg("drop", n); else wdgmsg("use", n); return (true); } return (super.globtype(key, ev)); }
/* * legt die Funktion auf die Tab button * Corsor spring zu nachsten Text Area */ public void keyPressed(KeyEvent key) { /* mit strg + g autogenerate Key */ // TODO: if (key.getKeyCode() == 71 && key.getModifiersEx() == 128) { generateKey(); } /* mit Tab TextArea vorwaerts gehen */ if (key.getKeyCode() == 9 && key.getModifiersEx() == 0) { setNextArea(); // closeCompoundEdit(); } /* mit shift+Tab TextArea rueckwaerts gehen */ if (key.getKeyCode() == 9 && key.getModifiersEx() == 64) { setBackArea(); // closeCompoundEdit(); } }
public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { KeyPressedEvent obj = (KeyPressedEvent) object; java.awt.event.KeyEvent src = obj.getSourceEvent(); serializer.serialize(buffer, src.getKeyChar()); serializer.serialize(buffer, src.getKeyCode()); serializer.serialize(buffer, src.getKeyLocation()); serializer.serialize(buffer, src.getID()); serializer.serialize(buffer, src.getModifiersEx()); serializer.serialize(buffer, src.getWhen()); }
@Override public void keyPressed(KeyEvent evt) { multicaster.keyPressed(evt); if (!evt.isConsumed()) { super.keyPressed(evt); // Forward key presses to the handler if (dragLocation != null) { multicaster.trackStep(anchor, dragLocation, evt.getModifiersEx(), getView()); } } }
@SuppressWarnings("HardCodedStringLiteral") private void processListSelection(final KeyEvent e) { if (togglePopup(e)) return; if (!isPopupShowing()) return; final InputMap map = myPathTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); if (map != null) { final Object object = map.get(KeyStroke.getKeyStrokeForEvent(e)); if (object instanceof Action) { final Action action = (Action) object; if (action.isEnabled()) { action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "action")); e.consume(); return; } } } final Object action = getAction(e, myList); if ("selectNextRow".equals(action)) { if (ensureSelectionExists()) { ListScrollingUtil.moveDown(myList, e.getModifiersEx()); } } else if ("selectPreviousRow".equals(action)) { ListScrollingUtil.moveUp(myList, e.getModifiersEx()); } else if ("scrollDown".equals(action)) { ListScrollingUtil.movePageDown(myList); } else if ("scrollUp".equals(action)) { ListScrollingUtil.movePageUp(myList); } else if (getSelectedFileFromCompletionPopup() != null && (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_TAB) && e.getModifiers() == 0) { hideCurrentPopup(); e.consume(); processChosenFromCompletion(e.getKeyCode() == KeyEvent.VK_TAB); } }
private void displayInfo(KeyEvent e, String keyStatus) { // Method copied from http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html // You should only rely on the key char if the event // is a key typed event. int id = e.getID(); String keyString; if (id == KeyEvent.KEY_TYPED) { char c = e.getKeyChar(); keyString = "key character = '" + c + "'"; } else { int keyCode = e.getKeyCode(); keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; } int modifiersEx = e.getModifiersEx(); String modString = "extended modifiers = " + modifiersEx; String tmpString = KeyEvent.getModifiersExText(modifiersEx); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no extended modifiers)"; } String actionString = "action key? "; if (e.isActionKey()) { actionString += "YES"; } else { actionString += "NO"; } String locationString = "key location: "; int location = e.getKeyLocation(); if (location == KeyEvent.KEY_LOCATION_STANDARD) { locationString += "standard"; } else if (location == KeyEvent.KEY_LOCATION_LEFT) { locationString += "left"; } else if (location == KeyEvent.KEY_LOCATION_RIGHT) { locationString += "right"; } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) { locationString += "numpad"; } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN) locationString += "unknown"; } // Added: System.out.println("Keypress: " + keyString); }
@Override public void keyPressed(Canvas canvas, KeyEvent e) { if (state == MOVING && e.getKeyCode() == KeyEvent.VK_SHIFT) { handleMoveDrag(canvas, curDx, curDy, e.getModifiersEx()); } else { switch (e.getKeyCode()) { case KeyEvent.VK_BACK_SPACE: case KeyEvent.VK_DELETE: if (!canvas.getSelection().isEmpty()) { Action act = SelectionActions.clear(canvas.getSelection()); canvas.getProject().doAction(act); e.consume(); } break; default: processKeyEvent(canvas, e, KeyConfigurationEvent.KEY_PRESSED); } } }
// KeyListener public void keyPressed(KeyEvent evt) { int modifiers = evt.getModifiersEx(); int keyCode = evt.getKeyCode(); // Ctrl + <key> int onmask = KeyEvent.CTRL_DOWN_MASK; int offmask = KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; if ((modifiers & (onmask | offmask)) == onmask) { /* if (keyCode == KeyEvent.VK_S) { ; } else if (keyCode == KeyEvent.VK_A) { ; } else if (keyCode == KeyEvent.VK_Q) { ; } else if (keyCode == KeyEvent.VK_N) { ; } else if (keyCode == KeyEvent.VK_O) { ; } else if (keyCode == KeyEvent.VK_W) { ; } */ ; } // Ctrl + Shift + <key> onmask = KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK; offmask = KeyEvent.ALT_DOWN_MASK; if ((modifiers & (onmask | offmask)) == onmask) { /* if (keyCode == KeyEvent.VK_S) { ; } */ } updateGui(); }
public boolean keydown(KeyEvent ev) { boolean M = (ev.getModifiersEx() & (KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)) != 0; if (qline != null) { if (M && (ev.getKeyCode() == KeyEvent.VK_UP)) { Channel prev = this.sel; while (chansel.up()) { if (this.sel instanceof EntryChannel) break; } if (!(this.sel instanceof EntryChannel)) { select(prev); return (true); } qline = new QuickLine((EntryChannel) sel); return (true); } else if (M && (ev.getKeyCode() == KeyEvent.VK_DOWN)) { Channel prev = this.sel; while (chansel.down()) { if (this.sel instanceof EntryChannel) break; } if (!(this.sel instanceof EntryChannel)) { select(prev); return (true); } qline = new QuickLine((EntryChannel) sel); return (true); } qline.key(ev); return (true); } else { if (M && (ev.getKeyCode() == KeyEvent.VK_UP)) { chansel.up(); return (true); } else if (M && (ev.getKeyCode() == KeyEvent.VK_DOWN)) { chansel.down(); return (true); } return (super.keydown(ev)); } }
@Override public synchronized void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); // If quick search is not active... if (!isActive()) { // Return (do not start quick search) if the key is not a valid quick search input if (!isValidQuickSearchInput(e)) { if (keyCode == KeyEvent.VK_ESCAPE || keyCode == KeyEvent.VK_ENTER) tryToTransferFocusToTheNextComponent(); if (keyCode == KeyEvent.VK_ENTER) ((QuickListWithDataList<T>) (getParent().getParent().getParent())) .itemSelected(getSelectedValue()); return; } // Start the quick search and continue to process the current key event start(); } // At this point, quick search is active boolean keyHasModifiers = (e.getModifiersEx() & (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK | KeyEvent.META_DOWN_MASK)) != 0; // Backspace removes the last character of the search string if (keyCode == KeyEvent.VK_BACK_SPACE && !keyHasModifiers) { // Search string is empty already if (isSearchStringEmpty()) { return; } removeLastCharacterFromSearchString(); // Find the row that best matches the new search string and select it findMatch(0, true, true); } // Escape immediately cancels the quick search else if (keyCode == KeyEvent.VK_ESCAPE && !keyHasModifiers) { stop(); } // Up/Down jumps to previous/next match // Shift+Up/Shift+Down marks currently selected file and jumps to previous/next match else if ((keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) && !keyHasModifiers) { // Find the first row before/after the current row that matches the search string boolean down = keyCode == KeyEvent.VK_DOWN; findMatch(getSelectedIndex() + (down ? 1 : -1), down, false); } // If no modifier other than Shift is pressed and the typed character is not a control // character (space is ok) // and a valid Unicode character, add it to the current search string else if (isValidQuickSearchInput(e)) { appendCharacterToSearchString(e.getKeyChar()); // Find the row that best matches the new search string and select it findMatch(0, true, true); } else { switch (e.getKeyCode()) { case KeyEvent.VK_UP: { int numOfItems = getModel().getSize(); if (numOfItems > 0 && getSelectedIndex() == 0) { setSelectedIndex(numOfItems - 1); ensureIndexIsVisible(numOfItems - 1); e.consume(); } } break; case KeyEvent.VK_DOWN: { int numOfItems = getModel().getSize(); if (numOfItems > 0 && getSelectedIndex() == numOfItems - 1) { setSelectedIndex(0); ensureIndexIsVisible(0); e.consume(); } } break; case KeyEvent.VK_ENTER: tryToTransferFocusToTheNextComponent(); ((QuickListWithDataList<T>) (getParent().getParent().getParent())) .itemSelected(getSelectedValue()); stop(); break; case KeyEvent.VK_TAB: tryToTransferFocusToTheNextComponent(); stop(); break; } // Do not update last search string's change timestamp return; } // Update last search string's change timestamp setLastSearchStringChange(System.currentTimeMillis()); e.consume(); }
@Override public void keyPressed(final KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_ENTER) { painter.interrupt(); imp.getCanvas().setDisplayList(null); gui.restoreGui(); if (e.getKeyCode() == KeyEvent.VK_ESCAPE) gui.close(); } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { dLambda *= 10; dPhi *= 10; } else if (e.getKeyCode() == KeyEvent.VK_CONTROL) { dLambda /= 10; dPhi /= 10; } else { final double v = keyModfiedSpeed(e.getModifiersEx()); if (e.getKeyCode() == KeyEvent.VK_LEFT) { lambda -= v * step; update(false); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { lambda += v * step; update(false); } else if (e.getKeyCode() == KeyEvent.VK_UP) { phi -= v * step; update(false); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { phi += v * step; update(false); } else if (e.getKeyCode() == KeyEvent.VK_PLUS || e.getKeyCode() == KeyEvent.VK_EQUALS) { p.setF(p.getF() * (1 + 0.1f * v)); update(false); } else if (e.getKeyCode() == KeyEvent.VK_MINUS) { p.setF(p.getF() / (1 + 0.1f * v)); update(false); } else if (e.getKeyCode() == KeyEvent.VK_SPACE) { renderCubeFaces(hfov, vfov); update(false); } else if (e.getKeyCode() == KeyEvent.VK_I) { painter.toggleInterpolation(); update(false); } else if (e.getKeyCode() == KeyEvent.VK_V) { painter.toggleVisualization(); imp.getCanvas().setDisplayList(null); update(false); } else if (e.getKeyCode() == KeyEvent.VK_A) { naviMode = NaviMode.PAN_TILT; dLambda = dPhi = 0; update(false); } else if (e.getKeyCode() == KeyEvent.VK_P) { naviMode = NaviMode.PAN_ONLY; dLambda = dPhi = 0; update(false); } else if (e.getKeyCode() == KeyEvent.VK_T) { naviMode = NaviMode.TILT_ONLY; dLambda = dPhi = 0; update(false); } else if (e.getKeyCode() == KeyEvent.VK_R) { naviMode = NaviMode.ROLL_ONLY; dLambda = dPhi = 0; update(false); } else if (e.getKeyCode() == KeyEvent.VK_F1) { IJ.showMessage( "Interactive Panorama Viewer", "Mouse control:" + NL + " " + NL + "Pan and tilt the panorama by dragging the image in the canvas and" + NL + "zoom in and out using the mouse-wheel." + NL + " " + NL + "Key control:" + NL + " " + NL + "CURSOR LEFT - Pan left." + NL + "CURSOR RIGHT - Pan right." + NL + "CURSOR UP - Tilt up." + NL + "CURSOR DOWN - Tilt down." + NL + "SHIFT - Move 10x faster." + NL + "CTRL - Move browse 10x slower." + NL + "ENTER/ESC - Leave interactive mode." + NL + "I - Toggle interpolation." + NL + "V - Toggle FOV visualization." + NL + "R - Roll-mode (roll via mouse drag)." + NL + "P - Pan/Tilt-mode (pan/tilt via mouse drag)."); } } }
private boolean inInitState() { Component focusOwner = myContext.getFocusOwner(); boolean isModalContext = myContext.isModalContext(); DataContext dataContext = myContext.getDataContext(); KeyEvent e = myContext.getInputEvent(); // http://www.jetbrains.net/jira/browse/IDEADEV-12372 if (myLeftCtrlPressed && myRightAltPressed && focusOwner != null && e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.ALT_MASK)) { if (Registry.is("actionSystem.force.alt.gr")) { return false; } final InputContext inputContext = focusOwner.getInputContext(); if (inputContext != null) { Locale locale = inputContext.getLocale(); if (locale != null) { @NonNls final String language = locale.getLanguage(); if (ALT_GR_LAYOUTS.contains(language)) { // don't search for shortcuts return false; } } } } KeyStroke originalKeyStroke = KeyStroke.getKeyStrokeForEvent(e); KeyStroke keyStroke = getKeyStrokeWithoutMouseModifiers(originalKeyStroke); if (myKeyGestureProcessor.processInitState()) { return true; } if (SystemInfo.isMac) { boolean keyTyped = e.getID() == KeyEvent.KEY_TYPED; boolean hasMnemonicsInWindow = e.getID() == KeyEvent.KEY_PRESSED && hasMnemonicInWindow(focusOwner, e.getKeyCode()) || keyTyped && hasMnemonicInWindow(focusOwner, e.getKeyChar()); boolean imEnabled = IdeEventQueue.getInstance().isInputMethodEnabled(); if (e.getModifiersEx() == InputEvent.ALT_DOWN_MASK && (hasMnemonicsInWindow || (!imEnabled && keyTyped))) { setPressedWasProcessed(true); setState(KeyState.STATE_PROCESSED); return false; } } updateCurrentContext(focusOwner, new KeyboardShortcut(keyStroke, null), isModalContext); if (myContext.getActions().isEmpty()) { // there's nothing mapped for this stroke return false; } if (myContext.isHasSecondStroke()) { myFirstKeyStroke = keyStroke; final ArrayList<Pair<AnAction, KeyStroke>> secondKeyStrokes = getSecondKeystrokeActions(); final Project project = PlatformDataKeys.PROJECT.getData(dataContext); StringBuilder message = new StringBuilder(); message.append(KeyMapBundle.message("prefix.key.pressed.message")); message.append(' '); for (int i = 0; i < secondKeyStrokes.size(); i++) { Pair<AnAction, KeyStroke> pair = secondKeyStrokes.get(i); if (i > 0) message.append(", "); message.append(pair.getFirst().getTemplatePresentation().getText()); message.append(" ("); message.append(KeymapUtil.getKeystrokeText(pair.getSecond())); message.append(")"); } StatusBar.Info.set(message.toString(), project); mySecondStrokeTimeout.cancelAllRequests(); mySecondStrokeTimeout.addRequest( mySecondStrokeTimeoutRunnable, Registry.intValue("actionSystem.secondKeystrokeTimeout")); if (Registry.is("actionSystem.secondKeystrokeAutoPopupEnabled")) { mySecondKeystrokePopupTimeout.cancelAllRequests(); if (secondKeyStrokes.size() > 1) { final DataContext oldContext = myContext.getDataContext(); mySecondKeystrokePopupTimeout.addRequest( new Runnable() { @Override public void run() { if (myState == KeyState.STATE_WAIT_FOR_SECOND_KEYSTROKE) { StatusBar.Info.set(null, PlatformDataKeys.PROJECT.getData(oldContext)); new SecondaryKeystrokePopup(myFirstKeyStroke, secondKeyStrokes, oldContext) .showInBestPositionFor(oldContext); } } }, Registry.intValue("actionSystem.secondKeystrokePopupTimeout")); } } setState(KeyState.STATE_WAIT_FOR_SECOND_KEYSTROKE); return true; } else { return processAction(e, myActionProcessor); } }
protected void doShift(KeyEvent e) { setSelectionModes(e.getModifiersEx()); super.doShift(e); }
public final void keyPressed(final KeyEvent aKeyEvent) { if (aKeyEvent.getKeyCode() != KeyEvent.VK_ENTER) return; if (aKeyEvent.getModifiersEx() != KeyEvent.ALT_DOWN_MASK) return; myFullScreenManager.toggleFullScreenMode(); }