textField.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode().equals(KeyCode.ENTER)) { doSomething(); } } });
private void delegateToTrack(MouseEvent event) { if (!event.isConsumed()) { event.consume(); track.fireEvent(event); } }
private void updateInitMouseValues(MouseEvent mouseEvent) { initStageX = primaryStage.getX(); initStageY = primaryStage.getY(); initWidth = primaryStage.getWidth(); initHeight = primaryStage.getHeight(); initX = mouseEvent.getScreenX(); initY = mouseEvent.getScreenY(); xOffset = mouseEvent.getSceneX(); yOffset = mouseEvent.getSceneY(); }
.filter(e -> !e.isConsumed()) .filter(e -> e.getEventType().equals(KeyEvent.KEY_RELEASED) && e.getCode() == KeyCode.ENTER || e.getEventType().equals(KeyEvent.KEY_PRESSED) && e.getCode() == KeyCode.TAB autoCompletePopup.getItems().get(focusIdx).getOnAction().handle(new ActionEvent()); e.consume(); }); .filter(key -> key.isControlDown() && key.getCode().equals(KeyCode.SPACE)) .map(searchPoint -> myCodeArea.getCaretPosition());
addEventHandler(MouseEvent.MOUSE_EXITED, event -> setFocusedSquare(null)); addEventHandler(MouseEvent.MOUSE_RELEASED, event -> { if (!dragDetected && event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 1) { if (!isEmpty) { Color fill = (Color) rectangle.getFill(); colorPicker.fireEvent(new ActionEvent()); updateSelection(fill); event.consume();
private void handleDragEventOnDecoratorPane(MouseEvent mouseEvent) { isDragging = true; if (!mouseEvent.isPrimaryButtonDown() || (xOffset == -1 && yOffset == -1)) { return; if (primaryStage.isFullScreen() || mouseEvent.isStillSincePress() || primaryStage.isMaximized() || maximized) { return; newX = mouseEvent.getScreenX(); newY = mouseEvent.getScreenY(); mouseEvent.consume(); } else if (Cursor.NE_RESIZE.equals(cursor)) { if (setStageHeight(initHeight - deltay)) { mouseEvent.consume(); } else if (Cursor.SE_RESIZE.equals(cursor)) { setStageWidth(initWidth + deltax); setStageHeight(initHeight + deltay); mouseEvent.consume(); } else if (Cursor.S_RESIZE.equals(cursor)) { setStageHeight(initHeight + deltay); mouseEvent.consume(); } else if (Cursor.W_RESIZE.equals(cursor)) { if (setStageWidth(initWidth - deltax)) { primaryStage.setX(initStageX + deltax); mouseEvent.consume(); } else if (Cursor.SW_RESIZE.equals(cursor)) { if (setStageWidth(initWidth - deltax)) {
private void registerEventListener() { suggestionList.setOnMouseClicked(me -> { if (me.getButton() == MouseButton.PRIMARY) { selectItem(); getSkinnable().hide(); } }); control.showingProperty().addListener((o, oldVal, newVal) -> { if (newVal) { animate(); } }); suggestionList.setOnKeyPressed(event -> { switch (event.getCode()) { case ENTER: selectItem(); getSkinnable().hide(); break; case ESCAPE: getSkinnable().hide(); break; default: break; } }); }
protected void initControlListeners() { // if the control got resized the overlay rect must be rest control.layoutBoundsProperty().addListener(observable -> resetRippler()); if (getChildren().contains(control)) { control.boundsInParentProperty().addListener(observable -> resetRippler()); } control.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> createRipple(event.getX() + padding, event.getY() + padding)); // create fade out transition for the ripple control.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> releaseRipple()); }
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); }
private ContextMenu buildContextMenu(Node item) { ContextMenu contextMenu = new ContextMenuWithNoArrows(); CustomMenuItem menuItem = new CustomMenuItem(new Label("Copy subtree test to clipboard...")); Tooltip tooltip = new Tooltip("Creates a node spec using the Kotlin AST matcher DSL, and dumps it to the clipboard"); Tooltip.install(menuItem.getContent(), tooltip); menuItem.setOnAction(e -> { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putString(dumpToSubtreeTest(item)); // item is captured in the closure clipboard.setContent(content); }); contextMenu.getItems().add(menuItem); return contextMenu; }
@Override protected void updateItem(Node item, boolean empty) { super.updateItem(item, empty); if (empty || item == null) { setText(null); setGraphic(null); return; } else { setText(item.toString() + (item.getImage() == null ? "" : " \"" + item.getImage() + "\"")); setContextMenu(buildContextMenu(item)); } // Reclicking the selected node in the ast will scroll back to the node in the editor this.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> { if (t.getButton() == MouseButton.PRIMARY && getTreeView().getSelectionModel().getSelectedItem().getValue() == item) { controller.onNodeItemSelected(item); t.consume(); } }); }
/** * propagate any mouse event on the tree table view to its parent */ public void propagateMouseEventsToParent() { this.addEventHandler(MouseEvent.ANY, e -> { e.consume(); this.getParent().fireEvent(e); }); }
public void selectColor(KeyEvent event) { if (rectangle.getFill() != null) { if (rectangle.getFill() instanceof Color) { colorPicker.setValue((Color) rectangle.getFill()); colorPicker.fireEvent(new ActionEvent()); } event.consume(); } colorPicker.hide(); } }
/** * init mouse listeners on the control */ protected void initControlListeners() { // if the control got resized the overlay rect must be rest control.layoutBoundsProperty().addListener(observable -> resetRippler()); if(getChildren().contains(control)) control.boundsInParentProperty().addListener(observable -> resetRippler()); control.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> createRipple(event.getX(), event.getY())); // create fade out transition for the ripple control.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> releaseRipple()); }
/** * propagate mouse events to the parent node ( e.g. to allow dragging while clicking on the list) */ public void propagateMouseEventsToParent() { this.addEventHandler(MouseEvent.ANY, e -> { e.consume(); this.getParent().fireEvent(e); }); }
@Override protected void starting() { super.starting(); if (node.getParent() instanceof JFXRippler) { JFXRippler rippler = (JFXRippler) node.getParent(); BorderPane p = new BorderPane(node); p.setMaxWidth(((JFXHamburger) node).getWidth()); p.setMinWidth(((JFXHamburger) node).getWidth()); p.addEventHandler(MouseEvent.ANY, (event) -> { if (!event.isConsumed()) { event.consume(); node.fireEvent(event); } }); rippler.setControl(p); } if (this.getRate() == -1) { ((JFXHamburger) node).getChildren().get(1).setVisible(true); } }
/** * propagate any mouse events on the tab pane to its parent */ public void propagateMouseEventsToParent() { this.addEventHandler(MouseEvent.ANY, e -> { e.consume(); this.getParent().fireEvent(e); }); }
private void initialize() { this.setVisible(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.transitionType.addListener((o, oldVal, newVal) -> { animation = getShowAnimation(transitionType.get()); }); contentHolder = new StackPane(); contentHolder.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(2), null))); JFXDepthManager.setDepth(contentHolder, 4); contentHolder.setPickOnBounds(false); // ensure stackpane is never resized beyond it's preferred size contentHolder.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); this.getChildren().add(contentHolder); this.getStyleClass().add("jfx-dialog-overlay-pane"); StackPane.setAlignment(contentHolder, Pos.CENTER); this.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), null, null))); // close the dialog if clicked on the overlay pane if (overlayClose.get()) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } // prevent propagating the events to overlay pane contentHolder.addEventHandler(MouseEvent.ANY, e -> e.consume()); }