/** KeyListener method. */ @Override public void keyPressed(KeyEvent ke) { animator.start(); int DELTA_SIZE = 1; switch (ke.getKeyCode()) { case KeyEvent.VK_UP: gcodeRenderer.pan(0, DELTA_SIZE); // this.eye.y+=DELTA_SIZE; break; case KeyEvent.VK_DOWN: gcodeRenderer.pan(0, -DELTA_SIZE); break; case KeyEvent.VK_LEFT: gcodeRenderer.pan(-DELTA_SIZE, 0); break; case KeyEvent.VK_RIGHT: gcodeRenderer.pan(DELTA_SIZE, 0); break; case KeyEvent.VK_MINUS: if (ke.isControlDown()) gcodeRenderer.zoom(-1); break; case KeyEvent.VK_0: case KeyEvent.VK_ESCAPE: gcodeRenderer.resetView(); break; } switch (ke.getKeyChar()) { case '+': if (ke.isControlDown()) gcodeRenderer.zoom(1); break; } }
public void keyReleased(KeyEvent e) { // Application.debug(e+""); /* test code to generate unicode strings for Virtual Keyboard String text = getText(); String outStr = ""; for (int i = 0 ; i < text.length() ; i++) { int ch = text.charAt(i); if (ch < 128) outStr += text.charAt(i); else { String unicode = Integer.toHexString(ch); if (unicode.length() < 4) unicode = "\\u0"+unicode; else unicode = "\\u"+unicode; outStr += unicode; } } Application.debug(outStr); //*/ // ctrl pressed on Mac // or alt on Windows boolean modifierKeyPressed = Application.MAC_OS ? e.isControlDown() : e.isAltDown(); // we don't want to act when AltGr is down // as it is used eg for entering {[}] is some locales // NB e.isAltGraphDown() doesn't work if (e.isAltDown() && e.isControlDown()) modifierKeyPressed = false; char charPressed = e.getKeyChar(); if ((!isLetterOrDigit(charPressed) && !modifierKeyPressed) || (ctrlC && Application.MAC_OS) // don't want selection cleared ) return; clearSelection(); // handle alt-p etc super.keyReleased(e); mergeKoreanDoubles(); if (getAutoComplete()) { updateCurrentWord(false); startAutoCompletion(); } /* if (charCodePressed == KeyEvent.VK_BACK_SPACE && isTextSelected && input.length() > 0) { setText(input.substring(0, input.length())); }*/ }
/** * Determines which button corresponds with a provided hot-key event. * * @param e the keyEvent generated by the user */ public void keyPressed(KeyEvent e) { // If control b is pressed, click bold if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_B) { boldAction(); } // If control i is pressed, click italics else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) { italicAction(); } // If control u is pressed, click underline else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_U) { underlineAction(); } }
@Override public void keyReleased(KeyEvent ke) { simulationBox.setSelectionAppend(ke.isControlDown()); if (!simulationBox.isTextEditing()) { if (ke.getKeyCode() == KeyEvent.VK_Z && ke.isControlDown()) { undo(); } if (ke.getKeyCode() == KeyEvent.VK_Y && ke.isControlDown()) { redo(); } if (ke.getKeyCode() == KeyEvent.VK_S && ke.isControlDown()) { save(); } } }
// #{GxwCbkHost_ public static final boolean ExecKeyEvent(GxwCbkHost host, KeyEvent e) { boolean rv = true; int id = e.getID(), val = e.getKeyCode(); boolean isAltF4 = false; if (e.isAltDown() && val == IptKey_.F4.Val()) { isAltF4 = true; } if (id == KeyEvent.KEY_TYPED) { IptEvtDataKeyHeld keyHeldData = IptEvtDataKeyHeld.char_(e.getKeyChar()); rv = host.KeyHeldCbk(keyHeldData); if (keyHeldData.Handled()) rv = false; } else { if (e.isShiftDown()) val |= IptKey_.Shift.Val(); if (e.isControlDown()) val |= IptKey_.Ctrl.Val(); if (e.isAltDown()) val |= IptKey_.Alt.Val(); IptEvtDataKey keyData = IptEvtDataKey.int_(val); // Tfds.Write(e.getKeyChar(), e.getKeyCode(), val, id); if (id == KeyEvent.KEY_PRESSED) rv = host.KeyDownCbk(keyData); else if (id == KeyEvent.KEY_RELEASED) rv = host.KeyUpCbk(keyData); if (keyData.Handled()) rv = false; // was false } if (isAltF4) { e.consume(); } if (e.getKeyCode() == KeyEvent.VK_ALT) e.consume(); // force consume of alt-keys; occurs when alt-f4ing out of video app (though // not audio app) return rv; }
public void keyPressed(KeyEvent event) { msg1 = ""; System.out.println("keyPressed " + event.getKeyCode()); if (event.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { int key = event.getKeyCode(); // Funktionstaste abfragen if (key == KeyEvent.VK_F1) { msg1 = "F1"; } else if (key == KeyEvent.VK_F2) { msg1 = "F2"; } else if (key == KeyEvent.VK_F3) { msg1 = "F3"; } // Modifier abfragen if (msg1.length() > 0) { if (event.isAltDown()) { msg1 = "ALT + " + msg1; } if (event.isControlDown()) { msg1 = "STRG + " + msg1; } if (event.isShiftDown()) { msg1 = "UMSCHALT + " + msg1; } } } repaint(); }
/** * Method declaration * * @param k */ public void keyTyped(KeyEvent k) { if (k.getKeyChar() == '\n' && k.isControlDown()) { k.consume(); execute(); } }
public boolean globtype(char k, KeyEvent ev) { if (ev.isAltDown() || ev.isControlDown() || k == 0) { return false; } k = (char) ev.getKeyCode(); if (Character.toUpperCase(k) != k) { return false; } if ((k == 27) && (this.cur != null)) { this.cur = null; curoff = 0; updlayout(); return (true); } else if ((k == KeyEvent.VK_N) && (layout[gsz.x - 2][gsz.y - 1] == next)) { use(next); return (true); } Pagina r = hotmap.get(k); if (r != null) { use(r); return (true); } return (false); }
public boolean processKeyPressed(final EditorContext editorContext, final KeyEvent keyEvent) { EditorComponent nodeEditor = editorContext.getNodeEditorComponent(); nodeEditor.hideMessageToolTip(); if (processKeyMaps(editorContext, keyEvent)) { return true; } jetbrains.mps.openapi.editor.cells.CellActionType actionType = editorContext.getNodeEditorComponent().getActionType(keyEvent, editorContext); EditorCell selectedCell = editorContext.getSelectedCell(); // process action if (selectedCell != null && actionType != null && editorContext .getEditorComponent() .getActionHandler() .executeAction(selectedCell, actionType)) { return true; } // special case - don't allow kbd focus to leave editor area if (keyEvent.getKeyCode() == KeyEvent.VK_UP && keyEvent.isControlDown() && !keyEvent.isAltDown() && !keyEvent.isShiftDown()) { keyEvent.consume(); } return false; }
@Action private void keyTyped(java.awt.event.KeyEvent evt) { // {{{ switch (evt.getKeyCode()) { case KeyEvent.VK_ENTER: // sendAsyncTweet(); btnTweet.doClick(); // sendTweetClicked().execute(); break; case KeyEvent.VK_M: if (evt.isControlDown()) view.showMiniMode(); break; case KeyEvent.VK_ESCAPE: view.getMainApp().toggleWindowView("down"); break; // default: // int c = txtTweet.getDocument().getLength(); // lblChars.setText((140 - c)+""); // if((c > 0) && (c < 141)) { // btnTweet.setEnabled(true); // lblChars.setForeground(getResourceMap().getColor("lblChars.foreground")); // } // else if(c > 140) { // lblChars.setForeground(Color.RED); // btnTweet.setEnabled(false); // } // else // { // btnTweet.setEnabled(false); // } } } // }}}
/** * The keyReleased event ensures that the caret-position is updated for both peers, when the * user moves the caret with the arrow-keys. */ public void keyReleased(KeyEvent e) { int left = e.VK_LEFT; int right = e.VK_RIGHT; int up = e.VK_UP; int down = e.VK_DOWN; int home = e.VK_HOME; int end = e.VK_END; int A = e.VK_A; int kc = e.getKeyCode(); if (kc == left || kc == right || kc == up || kc == down || kc == home || kc == end || (kc == A && e.isControlDown())) { if (dec == null) return; lc.increment(); TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp()); dec.sendObjectToAllPeers(cu); er.getEventHistoryLock().lock(); er.getEventHistory().add(cu); er.getEventHistoryLock().unlock(); } }
/** * Will deal with KEYCODE only * * @param ke */ @Override public void keyPressed(KeyEvent ke) { simulationBox.setSelectionAppend(ke.isControlDown()); switch (ke.getKeyCode()) { case KeyEvent.VK_ESCAPE: simulationBox.emptySelection(); break; case KeyEvent.VK_DELETE: if (simulationBox.isTextEditing()) { simulationBox.processKeyPressed(ke); } else { deleteNetworkElement(); } break; case KeyEvent.VK_ENTER: saveNetworkElementChangement(); break; case KeyEvent.VK_LEFT: simulationBox.leftArrow(); break; case KeyEvent.VK_RIGHT: simulationBox.rightArrow(); break; default: simulationBox.processKeyPressed(ke); } }
@Override public void keyPressed(final KeyEvent e) { if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) { if (!Character.isLetter(e.getKeyChar())) { return; } final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject()); final ActionCallback firstCharTyped = new ActionCallback(); focusManager.typeAheadUntil(firstCharTyped); myPanel.moveDown(); //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { public void run() { try { final Robot robot = new Robot(); final boolean shiftOn = e.isShiftDown(); final int code = e.getKeyCode(); if (shiftOn) { robot.keyPress(KeyEvent.VK_SHIFT); } robot.keyPress(code); robot.keyRelease(code); // don't release Shift firstCharTyped.setDone(); } catch (AWTException ignored) { } } }); } }
/** * Controls: * * <p>Space - toggle animation left - previous frame (when stopped) right - next frame (when * stopped) cmd-s or ctrl-s - save the image(open dialog) */ @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case (KeyEvent.VK_SPACE): { Viewer.toggleAnimated(); break; } case (KeyEvent.VK_LEFT): { if (!Viewer.isAnimated()) Viewer.previousFrame(); break; } case (KeyEvent.VK_RIGHT): { if (!Viewer.isAnimated()) Viewer.nextFrame(); break; } case (KeyEvent.VK_S): { if (!Viewer.isAnimated()) { if (e.isControlDown() || e.isMetaDown()) { JFileChooser chooser = new JFileChooser(); int result = chooser.showSaveDialog(null); if (result == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); if (!f.getAbsolutePath().endsWith(".png")) f = new File(f.getAbsolutePath().concat(".png")); try { ImageIO.write(Creator.buff, "PNG", f); JOptionPane.showMessageDialog(null, "Saved image successfully"); } catch (IOException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(null, "Could not save image"); } } } else { String result = JOptionPane.showInputDialog( null, "Enter seed: (Integer between -2^63 and 2^63-1)", "0"); try { long r = Long.parseLong(result); Viewer.setFrame(r); } catch (Exception ex) { // Just ignore } } } break; } case (KeyEvent.VK_M): { Viewer.incrementMode(); break; } } }
public void keyPressed(KeyEvent e) { if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) { JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "jpeg", "gif", "png"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { File imageFile = chooser.getSelectedFile(); BufferedImage img = null; try { img = ImageIO.read(imageFile); ImageModel p = new ImageModel(img, chooser.getSelectedFile().getAbsolutePath()); controller.insert(p, glyph.getCursor().getGlyphIndex()); } catch (IOException exception) { System.out.println("No file found"); } } } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_Z) { controller.undo(); } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_Y) { controller.redo(); } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { controller.delete(glyph.getCursor().getGlyphIndex()); } else if (e.getKeyCode() == KeyEvent.VK_UP) { System.out.println("UPPP"); controller.scrollUp(); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { System.out.println("Down"); controller.scrollDown(); } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_A) { ArrowModel arrow = new ArrowModel(); controller.insert(arrow, glyph.getCursor().getGlyphIndex()); } else if (!e.isControlDown() && !e.isAltDown()) { System.out.println(e.getKeyChar() + " callled "); CharacterModel c = new CharacterModel(e.getKeyChar()); System.out.println(glyph.getCursor().getGlyphIndex()); controller.insert(c, glyph.getCursor().getGlyphIndex()); } }
public void processKeyEvent(KeyEvent evt) { evt = KeyEventWorkaround.processKeyEvent(evt); if (evt == null) return; switch (evt.getID()) { case KeyEvent.KEY_TYPED: char ch = evt.getKeyChar(); if (!nonDigit && Character.isDigit(ch)) { super.processKeyEvent(evt); repeat = true; repeatCount = Integer.parseInt(action.getText()); } else { nonDigit = true; if (repeat) { passToView(evt); } else super.processKeyEvent(evt); } break; case KeyEvent.KEY_PRESSED: int keyCode = evt.getKeyCode(); if (evt.isActionKey() || evt.isControlDown() || evt.isAltDown() || evt.isMetaDown() || keyCode == KeyEvent.VK_BACK_SPACE || keyCode == KeyEvent.VK_DELETE || keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_ESCAPE) { nonDigit = true; if (repeat) { passToView(evt); break; } else if (keyCode == KeyEvent.VK_TAB) { complete(true); evt.consume(); } else if (keyCode == KeyEvent.VK_ESCAPE) { evt.consume(); if (popup != null) { popup.dispose(); popup = null; action.requestFocus(); } else { if (temp) view.removeToolBar(ActionBar.this); view.getEditPane().focusOnTextArea(); } break; } else if ((keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) && popup != null) { popup.list.processKeyEvent(evt); break; } } super.processKeyEvent(evt); break; } }
/** * Used for incremental search. Only activated when incremental is selected. * * <p>The variable incSearchPos keeps track of which entry was last checked. */ @Override public void keyTyped(KeyEvent e) { if (e.isControlDown()) { return; } if (panel != null) { goIncremental(); } }
// Special case for OS X, where Ctrl-Space is not detected as KEY_TYPED // https://github.com/processing/processing/issues/2699 private void processControlSpace(final KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_SPACE && event.isControlDown()) { // Provide completions only if it's enabled if (JavaMode.codeCompletionsEnabled) { Messages.log( "[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started"); fetchPhrase(); } } }
/** A key was released. Check whether a key-based move or resize operation has ended. */ public void keyReleased(KeyEvent evt) { if (moving && (!evt.isShiftDown())) { // key-based moving stopped selection.moveStopped(); moving = false; } else if (resizing && (!evt.isControlDown())) { // key-based moving stopped selection.moveStopped(); resizing = false; } graphEditor.repaint(); }
/** * handle event * * @param e event */ public void keyReleased(KeyEvent e) { if (e.isControlDown() && (e.getKeyCode() == KeyEvent.VK_P)) { List selectionSet = getSelection(); if (selectionSet.size() == 1) { showProperties((MetSymbol) selectionSet.get(0)); } return; } super.keyReleased(e); }
@Override public void keyPressed(KeyEvent key) { if (key.isControlDown()) { if (key.getKeyCode() == KeyEvent.VK_R) { recording = !recording; return; } if (key.getKeyCode() == KeyEvent.VK_S) { screenshot = true; return; } } Keys.keySet(key.getKeyCode(), true); }
public void keyReleased(KeyEvent e) { Node node = Core.getShared().getFocusManager().findFocusedNode(parent); org.joshy.gfx.event.KeyEvent evt = new org.joshy.gfx.event.KeyEvent( org.joshy.gfx.event.KeyEvent.KeyReleased, org.joshy.gfx.event.KeyEvent.getKeyCodeFromAWT(e.getKeyCode()), node, e.getKeyChar(), e.isShiftDown(), e.isControlDown(), e.isAltDown(), e.isMetaDown()); EventBus.getSystem().publish(evt); }
/** A key was pressed in the graph editor. */ public void keyPressed(KeyEvent evt) { boolean handled = true; // assume for a start that we are handling the // key here if (isArrowKey(evt)) { if (evt.isControlDown()) { // resizing if (!resizing) startKeyboardResize(); setKeyDelta(evt); selection.resize(keyDeltaX, keyDeltaY); } else if (evt.isShiftDown()) { // moving targets if (!moving) startKeyboardMove(); setKeyDelta(evt); selection.move(keyDeltaX, keyDeltaY); } else { // navigate the diagram navigate(evt); } } else if (isPlusOrMinusKey(evt)) { resizeWithFixedRatio(evt); } // dependency selection else if (evt.getKeyCode() == KeyEvent.VK_PAGE_UP || evt.getKeyCode() == KeyEvent.VK_PAGE_DOWN) { selectDependency(evt); } // post context menu else if (evt.getKeyCode() == KeyEvent.VK_SPACE || evt.getKeyCode() == KeyEvent.VK_ENTER) { postMenu(); } // 'A' (with any or no modifiers) selects all else if (evt.getKeyCode() == KeyEvent.VK_A) { selectAll(); } // Escape removes selections else if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) { if (moving || resizing) { endMove(); } clearSelection(); } else { handled = false; } if (handled) evt.consume(); graphEditor.repaint(); }
public boolean globtype(char key, KeyEvent ev) { if (!super.globtype(key, ev)) { int code = ev.getKeyCode(); boolean ctrl = ev.isControlDown(); boolean alt = ev.isAltDown(); if (Config.profile && (key == '`')) { new Profwnd(ui.slen, ui.mainview.prof, "MV prof"); } else if (Config.profile && (key == '~')) { new Profwnd(ui.slen, gprof, "Glob prof"); } else if (Config.profile && (key == '!')) { new Profwnd(ui.slen, ui.mainview.mask.prof, "ILM prof"); } else if ((code == KeyEvent.VK_N) && ctrl) { Config.nightvision = !Config.nightvision; } else if ((code == KeyEvent.VK_X) && ctrl) { Config.xray = !Config.xray; } else if ((code == KeyEvent.VK_Z) && ctrl) { Config.assign_to_tile = !Config.assign_to_tile; } else if ((code == KeyEvent.VK_H) && ctrl) { Config.hide = !Config.hide; } else if ((code == KeyEvent.VK_Q) && alt) { ui.spd.setspeed(0, true); } else if ((code == KeyEvent.VK_W) && alt) { ui.spd.setspeed(1, true); } else if ((code == KeyEvent.VK_E) && alt) { ui.spd.setspeed(2, true); } else if ((code == KeyEvent.VK_R) && alt) { ui.spd.setspeed(3, true); } else if ((code == KeyEvent.VK_G) && ctrl) { Config.grid = !Config.grid; } else if (((int) key == 2) & ctrl) { // CTRL-B have code of 02 BuddyWnd.instance.visible = !BuddyWnd.instance.visible; } else if (((int) key == 20) & ctrl) { // CTRL-T have code of 20 CharWnd.instance.toggle(); } else if (code == KeyEvent.VK_HOME) { ui.mainview.resetcam(); } else if (code == KeyEvent.VK_END) { screenshot = true; } else if (key == ':') { entercmd(); } else if (key != 0) { wdgmsg("gk", (int) key); } } return (true); }
@Override public void keyPressed(KeyEvent ke) { // System.out.println("key pressed:"+ke.getKeyCode()); if (ke.isControlDown()) { if (ke.getKeyCode() == 67) { // Ctrl+c = copy menu.copy(); } else if (ke.getKeyCode() == 88) { // Ctrl+x = cut menu.copy(); menu.delete(); } else if (ke.getKeyCode() == 86) { // Ctrl+v = paste menu.paste(); } else if (ke.getKeyCode() == 79) { // Ctrl+o = open menu.open(); } else if (ke.getKeyCode() == 83) { // Ctrl+s = save menu.save(); } } if (ke.getKeyCode() == 38) { // Up key for (Bead bead : multiSelect) { if (bead.getTrack() > 1) { bead.setTrack(bead.getTrack() - 1); bead.setLocation(bead.getX(), bead.getY() - beadPlayer1.TRACKHEIGHT); } } } else if (ke.getKeyCode() == 40) { // Down key for (Bead bead : multiSelect) { if (bead.getTrack() < 8) { bead.setTrack(bead.getTrack() + 1); bead.setLocation(bead.getX(), bead.getY() + beadPlayer1.TRACKHEIGHT); } } } else if (ke.getKeyCode() == 37) { // Left key for (Bead bead : multiSelect) { if (bead.getX() > 55) bead.setLocation(bead.getX() - beadPlayer1.BEADHEIGHT, bead.getY()); } } else if (ke.getKeyCode() == 39) { // Right key for (Bead bead : multiSelect) { if (bead.getX() < 1000) bead.setLocation(bead.getX() + beadPlayer1.BEADHEIGHT, bead.getY()); } } else if (ke.getKeyCode() == 127 || ke.getKeyCode() == 8) { // delete/backspace key menu.delete(); } }
private void processKey(KeyEvent e) // handles termination, help, and game-play keys { int keyCode = e.getKeyCode(); // termination keys // listen for esc, q, end, ctrl-c on the canvas to // allow a convenient exit from the full screen configuration if ((keyCode == KeyEvent.VK_ESCAPE) || (keyCode == KeyEvent.VK_Q) || (keyCode == KeyEvent.VK_END) || ((keyCode == KeyEvent.VK_C) && e.isControlDown())) running = false; // help controls if (keyCode == KeyEvent.VK_H) { if (showHelp) { // help being shown showHelp = false; // switch off isPaused = false; } else { // help not being shown showHelp = true; // show it isPaused = true; // isPaused may already be true } } // game-play keys if (!isPaused && !gameOver) { // move the sprite and ribbons based on the arrow key pressed if (keyCode == KeyEvent.VK_LEFT) { jack.moveLeft(); bricksMan.moveRight(); // bricks and ribbons move the other way ribsMan.moveRight(); } else if (keyCode == KeyEvent.VK_RIGHT) { jack.moveRight(); bricksMan.moveLeft(); ribsMan.moveLeft(); } else if (keyCode == KeyEvent.VK_UP) jack.jump(); // jumping has no effect on the bricks/ribbons else if (keyCode == KeyEvent.VK_DOWN) { jack.stayStill(); bricksMan.stayStill(); ribsMan.stayStill(); } } } // end of processKey()
private void processCompletionKeys(final KeyEvent event) { char keyChar = event.getKeyChar(); int keyCode = event.getKeyCode(); if (keyChar == KeyEvent.VK_ENTER || keyChar == KeyEvent.VK_ESCAPE || keyChar == KeyEvent.VK_TAB || (event.getID() == KeyEvent.KEY_RELEASED && keyCode != KeyEvent.VK_LEFT && keyCode != KeyEvent.VK_RIGHT)) { // ignore } else if (keyChar == ')') { // https://github.com/processing/processing/issues/2741 hideSuggestion(); } else if (keyChar == '.') { if (JavaMode.codeCompletionsEnabled) { Messages.log( "[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started"); fetchPhrase(); } } else if (keyChar == ' ') { // Trigger on Ctrl-Space if (!Platform.isMacOS() && JavaMode.codeCompletionsEnabled && (event.isControlDown() || event.isMetaDown())) { // Provide completions only if it's enabled if (JavaMode.codeCompletionsEnabled) { // Removed for https://github.com/processing/processing/issues/3847 // try { // getDocument().remove(getCaretPosition() - 1, 1); // Remove the typed space Messages.log("[KeyEvent]" + event.getKeyChar() + " |Prediction started"); fetchPhrase(); // } catch (BadLocationException e) { // e.printStackTrace(); // } } } else { hideSuggestion(); // hide on spacebar } } else { if (JavaMode.codeCompletionsEnabled) { prepareSuggestions(event); } } }
@Override public void keyReleased(final KeyEvent e) { final int keyCode = e.getKeyCode(); /* Ignore if the key is not found in the pressedStateKeys list. */ if (client.keyIsPressed(keyCode)) { /* Remove keyCode from pressedStateKeys list. */ client.onKeyReleased(keyCode); switch (keyCode) { case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: /* * Ctrl means face, otherwise move */ processDirectionRelease(keyCodeToDirection(e.getKeyCode()), e.isControlDown()); } } }
private void tfdPrecoVendaKeyReleased( java.awt.event.KeyEvent evt) { // GEN-FIRST:event_tfdPrecoVendaKeyReleased // TODO add your handling code here: String value = tfdPrecoVenda.getText(); if (!value.trim().equals("")) { if (Util.isDouble(value)) { if (value.length() > 1 && value.charAt(0) == '.') tfdPrecoVenda.setBackground(new Color(255, 115, 115)); else { tfdPrecoVenda.setBackground(new Color(150, 255, 150)); lblVendaValidator.setText("..."); int keyCode = evt.getKeyCode(); if (evt.isControlDown() && keyCode == KeyEvent.VK_ENTER) cadastrar(); } } else { tfdPrecoVenda.setBackground(new Color(255, 115, 115)); if (value.indexOf(',') != -1) lblVendaValidator.setText("Troque a ',' por '.'"); } } else tfdPrecoVenda.setBackground(Color.white); } // GEN-LAST:event_tfdPrecoVendaKeyReleased
/** * Returns true if the pressed key includes a control key. * * @param e key event * @return result of check */ public static boolean control(final KeyEvent e) { // Mac offers special characters via ALT, Windows/Linux don't.. return e.isControlDown() || e.isMetaDown() || !MAC && e.isAltDown(); }