List of usage examples for javafx.scene.input KeyEvent isControlDown
public final boolean isControlDown()
From source file:Main.java
private static int modifiers(final InputEvent event) { if (event instanceof MouseEvent) { final MouseEvent mouseEvent = (MouseEvent) event; int modifiers = 0; if (mouseEvent.isAltDown()) { modifiers |= java.awt.event.MouseEvent.ALT_MASK; modifiers |= java.awt.event.MouseEvent.ALT_DOWN_MASK; }/*w ww . j a v a2 s . com*/ if (mouseEvent.isControlDown()) { modifiers |= java.awt.event.MouseEvent.CTRL_MASK; modifiers |= java.awt.event.MouseEvent.CTRL_DOWN_MASK; } if (mouseEvent.isMetaDown()) { modifiers |= java.awt.event.MouseEvent.META_MASK; modifiers |= java.awt.event.MouseEvent.META_DOWN_MASK; } if (mouseEvent.isShiftDown()) { modifiers |= java.awt.event.MouseEvent.SHIFT_MASK; modifiers |= java.awt.event.MouseEvent.SHIFT_DOWN_MASK; } if (mouseEvent.isPrimaryButtonDown()) { modifiers |= java.awt.event.MouseEvent.BUTTON1_MASK; } if (mouseEvent.isMiddleButtonDown()) { modifiers |= java.awt.event.MouseEvent.BUTTON2_MASK; } if (mouseEvent.isSecondaryButtonDown()) { modifiers |= java.awt.event.MouseEvent.BUTTON3_MASK; } return modifiers; } if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; int modifiers = 0; if (keyEvent.isAltDown()) { modifiers |= java.awt.event.KeyEvent.ALT_MASK; } if (keyEvent.isControlDown()) { modifiers |= java.awt.event.KeyEvent.CTRL_MASK; } if (keyEvent.isMetaDown()) { modifiers |= java.awt.event.KeyEvent.META_MASK; } if (keyEvent.isShiftDown()) { modifiers |= java.awt.event.KeyEvent.SHIFT_MASK; } return modifiers; } return 0; }
From source file:Main.java
/** * Handle action related to input (in this case specifically only responds to * keyboard event CTRL-A).//from ww w .ja v a 2 s . c o m * * @param event Input event. */ @FXML private void handleKeyInput(final InputEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) { provideAboutFunctionality(); } } }
From source file:com.properned.application.SystemController.java
public void loadFileList(File selectedFile) { Platform.runLater(new Runnable() { @Override//from ww w .j av a 2s.c o m public void run() { logger.info("Load the file list associated to '" + selectedFile.getAbsolutePath() + "'"); if (MultiLanguageProperties.getInstance().getIsDirty()) { ButtonType result = askForSave(); if (result.getButtonData() == ButtonData.CANCEL_CLOSE) { // The file must not be loaded return; } } Preferences.getInstance().setLastPathUsed(selectedFile.getAbsolutePath()); String fileName = selectedFile.getName(); String baseNameTemp = fileName.substring(0, fileName.lastIndexOf(".")); if (fileName.contains("_")) { baseNameTemp = fileName.substring(0, fileName.indexOf("_")); } final String baseName = baseNameTemp; List<PropertiesFile> fileList = Arrays .asList(selectedFile.getParentFile().listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().startsWith(baseName) && pathname.getName().endsWith(".properties"); } })).stream().map(new Function<File, PropertiesFile>() { @Override public PropertiesFile apply(File t) { String language = ""; if (t.getName().contains("_")) { language = t.getName().substring(t.getName().indexOf("_") + 1, t.getName().lastIndexOf(".")); } return new PropertiesFile(t.getAbsolutePath(), baseName, new Locale(language)); } }).collect(Collectors.<PropertiesFile>toList()); try { multiLanguageProperties.loadFileList(baseName, fileList); Preferences.getInstance().addFileToRecentFileList(selectedFile.getAbsolutePath()); Properned.getInstance().getPrimaryStage().getScene() .setOnKeyReleased(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.S && event.isControlDown()) { logger.info("CTRL-S detected"); save(); event.consume(); } } }); } catch (IOException e) { Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.load"), e); } } }); }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Handle action related to input (in this case specifically only responds * to keyboard event CTRL-A).//ww w. ja v a 2 s. c o m * * @param event Input event. */ @FXML public void handleKeyInput(final InputEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) { provideAboutFunctionality(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.R) { showReportOptionsDialog(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.O) { openFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.S) { saveFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.L) { showLoggerDialog(); } } }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblContexts_OnKeyPressed(KeyEvent keyEvent) { if (keyEvent.isControlDown()) { if (keyEvent.getCode().getName().equals("C")) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); Context context = tblContexts.getSelectionModel().getSelectedItem(); content.putString(context.getTextSegment()); clipboard.setContent(content); }/*from w ww. ja v a 2 s. c o m*/ } }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblTerms_OnKeyPressed(KeyEvent keyEvent) { if (keyEvent.isControlDown()) { // LOG.debug("keyEvent.getCharacter(): " + keyEvent.getCharacter()); // LOG.debug("keyEvent.getCode().getName(): " + keyEvent.getCode().getName()); if (keyEvent.getCode().getName().equals("C")) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); Term term = tblTerms.getSelectionModel().getSelectedItem(); content.putString(term.getText()); clipboard.setContent(content); }/*from w w w. j a v a 2s .com*/ } else if (keyEvent.getCode().getName().equalsIgnoreCase("M")) { this.markTerm(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("E")) { this.doExpansions(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("B")) { this.doBack(); } else if (keyEvent.getCode().getName().equalsIgnoreCase("F")) { this.doForward(); } }
From source file:com.panemu.tiwulfx.control.skin.LookupFieldSkin.java
public LookupFieldSkin(LookupField<T> control) { super(control, new LookupFieldBehavior<>(control)); this.lookupField = control; // move focus in to the textfield lookupField.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override//from ww w. j a v a 2 s. co m public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean hasFocus) { if (hasFocus) { Platform.runLater(new Runnable() { @Override public void run() { textField.requestFocus(); } }); } } }); initialize(); textField.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean hasFocus) { if (!hasFocus) { validate(); } } }); lookupField.addEventFilter(InputEvent.ANY, new EventHandler<InputEvent>() { @Override public void handle(InputEvent t) { if (textField == null) { return; } // When the user hits the enter or F4 keys, we respond before // ever giving the event to the TextField. if (t instanceof KeyEvent) { KeyEvent ke = (KeyEvent) t; if ((ke.getCode() == KeyCode.F10 || ke.getCode() == KeyCode.ESCAPE || ke.getCode() == KeyCode.ENTER) && !ke.isControlDown()) { // RT-23275: The TextField fires F10 and ESCAPE key events // up to the parent, which are then fired back at the // TextField, and this ends up in an infinite loop until // the stack overflows. So, here we consume these two // events and stop them from going any further. t.consume(); return; } } } }); textField.promptTextProperty().bind(lookupField.promptTextProperty()); getSkinnable().requestLayout(); registerChangeListener(control.showingSuggestionProperty(), PROP_SHOWING_SUGGESTION); registerChangeListener(control.showingLookupDialogProperty(), PROP_SHOWING_LOOKUP_WINDOW); registerChangeListener(control.resettingDisplayTextProperty(), PROP_RESETTING_DISPLAY_TEXT); }
From source file:nars.rl.util.ThreeDView.java
private void handleKeyboard(Scene scene, final Node root) { final boolean moveCamera = true; scene.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override/*from w w w .jav a 2s . co m*/ public void handle(KeyEvent event) { Duration currentTime; switch (event.getCode()) { case Z: if (event.isShiftDown()) { cameraXform.ry.setAngle(0.0); cameraXform.rx.setAngle(0.0); camera.setTranslateZ(-300.0); } cameraXform2.t.setX(0.0); cameraXform2.t.setY(0.0); break; case X: if (event.isControlDown()) { if (axisGroup.isVisible()) { axisGroup.setVisible(false); } else { axisGroup.setVisible(true); } } break; case S: if (event.isControlDown()) { if (space.isVisible()) { space.setVisible(false); } else { space.setVisible(true); } } break; case SPACE: if (timelinePlaying) { timeline.pause(); timelinePlaying = false; } else { timeline.play(); timelinePlaying = true; } break; case UP: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setY(cameraXform2.t.getY() - 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 10.0 * ALT_MULTIPLIER); } else if (event.isControlDown()) { cameraXform2.t.setY(cameraXform2.t.getY() - 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 2.0 * ALT_MULTIPLIER); } else if (event.isShiftDown()) { double z = camera.getTranslateZ(); double newZ = z + 5.0 * SHIFT_MULTIPLIER; camera.setTranslateZ(newZ); } break; case DOWN: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setY(cameraXform2.t.getY() + 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 10.0 * ALT_MULTIPLIER); } else if (event.isControlDown()) { cameraXform2.t.setY(cameraXform2.t.getY() + 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 2.0 * ALT_MULTIPLIER); } else if (event.isShiftDown()) { double z = camera.getTranslateZ(); double newZ = z - 5.0 * SHIFT_MULTIPLIER; camera.setTranslateZ(newZ); } break; case RIGHT: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setX(cameraXform2.t.getX() + 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 10.0 * ALT_MULTIPLIER); } else if (event.isControlDown()) { cameraXform2.t.setX(cameraXform2.t.getX() + 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 2.0 * ALT_MULTIPLIER); } break; case LEFT: if (event.isControlDown() && event.isShiftDown()) { cameraXform2.t.setX(cameraXform2.t.getX() - 10.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown() && event.isShiftDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 10.0 * ALT_MULTIPLIER); // - } else if (event.isControlDown()) { cameraXform2.t.setX(cameraXform2.t.getX() - 1.0 * CONTROL_MULTIPLIER); } else if (event.isAltDown()) { cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 2.0 * ALT_MULTIPLIER); // - } break; } } }); }