Java Code Examples for javafx.scene.input.KeyCode#ESCAPE
The following examples show how to use
javafx.scene.input.KeyCode#ESCAPE .
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: GenericEditableTreeTableCell.java From JFoenix with Apache License 2.0 | 6 votes |
private void createEditorNode() { EventHandler<KeyEvent> keyEventsHandler = t -> { if (t.getCode() == KeyCode.ENTER) { commitHelper(false); } else if (t.getCode() == KeyCode.ESCAPE) { cancelEdit(); } else if (t.getCode() == KeyCode.TAB) { commitHelper(false); editNext(!t.isShiftDown()); } }; ChangeListener<Boolean> focusChangeListener = (observable, oldValue, newValue) -> { //This focus listener fires at the end of cell editing when focus is lost //and when enter is pressed (because that causes the text field to lose focus). //The problem is that if enter is pressed then cancelEdit is called before this //listener runs and therefore the text field has been cleaned up. If the //text field is null we don't commit the edit. This has the useful side effect //of stopping the double commit. if (editorNode != null && !newValue) { commitHelper(true); } }; editorNode = builder.createNode(getValue(), keyEventsHandler, focusChangeListener); }
Example 2
Source File: GenericEditableTableCell.java From JFoenix with Apache License 2.0 | 6 votes |
private void createEditorNode() { EventHandler<KeyEvent> keyEventsHandler = t -> { if (t.getCode() == KeyCode.ENTER) { commitHelper(false); } else if (t.getCode() == KeyCode.ESCAPE) { cancelEdit(); } else if (t.getCode() == KeyCode.TAB) { commitHelper(false); editNext(!t.isShiftDown()); } }; ChangeListener<Boolean> focusChangeListener = (observable, oldValue, newValue) -> { //This focus listener fires at the end of cell editing when focus is lost //and when enter is pressed (because that causes the text field to lose focus). //The problem is that if enter is pressed then cancelEdit is called before this //listener runs and therefore the text field has been cleaned up. If the //text field is null we don't commit the edit. This has the useful side effect //of stopping the double commit. if (editorNode != null && !newValue) { commitHelper(true); } }; editorNode = builder.createNode(getValue(), keyEventsHandler, focusChangeListener); }
Example 3
Source File: RecordingListController.java From archivo with GNU General Public License v3.0 | 6 votes |
/** * When the text in the search field changes, check whether we should show the entire recording list or just * a subset. If a subset, start a timer so that we don't keep filtering while the user is still typing, and cancel * any existing timers. When the timer elapses, perform the filtering. */ @FXML public void searchFieldChanged(KeyEvent event) { if (event.getCode() == KeyCode.ESCAPE) { hideSearchBar(null); } else { String search = searchField.getText(); if (search.isEmpty()) { showAllRecordings(); } else { if (filterTimer != null) { filterTimer.cancel(); } filterTimer = new Timer(); filterTimer.schedule(new TimerTask() { @Override public void run() { Platform.runLater(() -> onlyShowMatchingRecordings(search)); } }, FILTER_AFTER_MS); } } }
Example 4
Source File: JsonTabController.java From dev-tools with Apache License 2.0 | 5 votes |
@FXML private void handleSearchBarEvent(final KeyEvent event) { if (event.isControlDown() && event.getCode() == KeyCode.F) { barSearch.setVisible(true); barSearch.setManaged(true); fieldSearch.requestFocus(); } else if (event.getCode() == KeyCode.ESCAPE) { barSearch.setVisible(false); barSearch.setManaged(false); } }
Example 5
Source File: EditorDialog.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Process key. * * @param event the event */ @FxThread protected void processKey(@NotNull KeyEvent event) { event.consume(); if (event.getCode() == KeyCode.ESCAPE) { hide(); } }
Example 6
Source File: MainScene.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void handle(KeyEvent t) { if (t.getCode() == KeyCode.ESCAPE) { if (masterClock.isPaused()) { masterClock.setPaused(false, true); } else { masterClock.setPaused(true, true); } } }
Example 7
Source File: SandboxModeMediator.java From metastone with GNU General Public License v2.0 | 5 votes |
@Override public void handle(KeyEvent keyEvent) { if (keyEvent.getCode() != KeyCode.ESCAPE) { return; } view.disableTargetSelection(); }
Example 8
Source File: PlayModeMediator.java From metastone with GNU General Public License v2.0 | 5 votes |
@Override public void handle(KeyEvent keyEvent) { if (keyEvent.getCode() != KeyCode.ESCAPE) { return; } view.disableTargetSelection(); }
Example 9
Source File: SortedChoiceController.java From BetonQuest-Editor with GNU General Public License v3.0 | 5 votes |
@FXML private void key(KeyEvent event) { try { if (event.getCode() == KeyCode.ESCAPE) { stage.close(); refresher.refresh(); return; } if (event.getCode() == KeyCode.DELETE && list.isFocused()) { delete(); return; } W item = list.getSelectionModel().getSelectedItem(); if (item != null) { int index = list.getItems().indexOf(item); if (moveUp.match(event)) { if (index > 0) { list.getItems().set(index, list.getItems().get(index - 1)); list.getItems().set(index - 1, item); } return; } else if (moveDown.match(event)) { if (index + 1 < list.getItems().size()) { list.getItems().set(index, list.getItems().get(index + 1)); list.getItems().set(index + 1, item); } return; } list.getSelectionModel().select(item); } if (item instanceof ConditionWrapper && invert.match(event)) { ConditionListCell.invert((ConditionWrapper) item); } } catch (Exception e) { ExceptionController.display(e); } }
Example 10
Source File: KeyEventHandler.java From CrazyAlpha with GNU General Public License v2.0 | 4 votes |
@Override public void handle(KeyEvent keyEvent) { boolean mapShake = false; if (keyEvent.getEventType() == KeyEvent.KEY_PRESSED) { // 地图震动 if (mapShake) Game.getInstance().getMapManager().getCurrentMap().start(); ((CenterArc) Game.getInstance().getModelManager().get("CenterArc")).changeStrokeColor(); String keyAlpha = keyEvent.getText().toUpperCase(); Alpha alpha = (Alpha) Game.getInstance().getModelManager().get(keyAlpha); if (alpha == null) { Game.getInstance().getMissMusic().play(); ((HPIndicator) Game.getInstance().getModelManager().get("HPIndicator")).miss(); logger.info("missed {} !", keyAlpha); return; } if (alpha.getStatus() == ObjectStatus.ANIMATION) { Game.getInstance().debug("hint {}!", keyAlpha); Game.getInstance().getHintMusic().play(); int gainScore = ((ScoreIndicator) Game.getInstance().getModelManager().get("ScoreIndicator")).hint(alpha); ScoreGadget scoreGadget = (ScoreGadget) Game.getInstance().getModelManager().getInvisibleModel(ScoreGadget.class); if (scoreGadget == null) scoreGadget = new ScoreGadget(); scoreGadget.setText("+" + String.valueOf(gainScore)); scoreGadget.setX(alpha.getX()); scoreGadget.setY(alpha.getY()); scoreGadget.setFillColor(alpha.getFillColor()); Game.getInstance().getModelManager().register(scoreGadget, String.valueOf(RandomEx.nextInt())); scoreGadget.start(); alpha.stop(); } else { Game.getInstance().getMissMusic().play(); ((HPIndicator) Game.getInstance().getModelManager().get("HPIndicator")).miss(); logger.info("missed {} !", keyAlpha); } } if (keyEvent.getEventType() == KeyEvent.KEY_RELEASED) { if (mapShake) Game.getInstance().getMapManager().getCurrentMap().stop(); Game.getInstance().getHintMusic().stop(); Game.getInstance().getMissMusic().stop(); ((CenterArc) Game.getInstance().getModelManager().get("CenterArc")).changeFillColor(); } if (keyEvent.getCode() == KeyCode.ESCAPE) { if (Game.getInstance().getStatus() == GameStatus.PAUSE) Game.getInstance().resume(); else if (Game.getInstance().getStatus() == GameStatus.RUNNING) Game.getInstance().pause(); } }
Example 11
Source File: WSRecorder.java From marathonv5 with Apache License 2.0 | 4 votes |
private boolean needManualRecording(KeyCode keyCode) { return keyCode == KeyCode.BACK_SPACE || keyCode == KeyCode.DELETE || keyCode == KeyCode.ESCAPE || keyCode == KeyCode.SPACE; }
Example 12
Source File: CreateAndSaveKMLFileController.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
/** * Discard or commit the current sketch to a KML placemark if ESCAPE or ENTER are pressed while sketching. * * @param keyEvent the key event */ @FXML private void handleKeyReleased(KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ESCAPE) { // clear the current sketch and start a new sketch startSketch(); } else if (keyEvent.getCode() == KeyCode.ENTER && sketchEditor.isSketchValid()) { // project the sketched geometry to WGS84 to comply with the KML standard Geometry sketchGeometry = sketchEditor.getGeometry(); Geometry projectedGeometry = GeometryEngine.project(sketchGeometry, SpatialReferences.getWgs84()); // create a new KML placemark KmlGeometry kmlGeometry = new KmlGeometry(projectedGeometry, KmlAltitudeMode.CLAMP_TO_GROUND); KmlPlacemark currentKmlPlacemark = new KmlPlacemark(kmlGeometry); // update the style of the current KML placemark KmlStyle kmlStyle = new KmlStyle(); currentKmlPlacemark.setStyle(kmlStyle); // set the selected style for the placemark switch (sketchGeometry.getGeometryType()) { case POINT: if (pointSymbolComboBox.getSelectionModel().getSelectedItem() != null) { String iconURI = pointSymbolComboBox.getSelectionModel().getSelectedItem(); KmlIcon kmlIcon = new KmlIcon(iconURI); KmlIconStyle kmlIconStyle = new KmlIconStyle(kmlIcon, 1); kmlStyle.setIconStyle(kmlIconStyle); } break; case POLYLINE: Color polylineColor = colorPicker.getValue(); if (polylineColor != null) { KmlLineStyle kmlLineStyle = new KmlLineStyle(ColorUtil.colorToArgb(polylineColor), 8); kmlStyle.setLineStyle(kmlLineStyle); } break; case POLYGON: Color polygonColor = colorPicker.getValue(); if (polygonColor != null) { KmlPolygonStyle kmlPolygonStyle = new KmlPolygonStyle(ColorUtil.colorToArgb(polygonColor)); kmlPolygonStyle.setFilled(true); kmlPolygonStyle.setOutlined(false); kmlStyle.setPolygonStyle(kmlPolygonStyle); } break; } // add the placemark to the kml document kmlDocument.getChildNodes().add(currentKmlPlacemark); // start a new sketch startSketch(); } }