Java Code Examples for javafx.scene.Group#setOnMouseClicked()
The following examples show how to use
javafx.scene.Group#setOnMouseClicked() .
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: ClearingTextField.java From phoebus with Eclipse Public License 1.0 | 5 votes |
public CustomSkin(TextField text) { super(text); // Circle with central 'x' as clear button final Circle circle = new Circle(); circle.setFill(Color.GRAY); circle.radiusProperty().bind(text.heightProperty().multiply(0.325)); circle.setFocusTraversable(false); final Line line1 = new Line(); line1.setStroke(Color.WHITE); line1.setStrokeWidth(1.7); line1.startXProperty().bind(text.heightProperty().multiply(-0.1)); line1.startYProperty().bind(text.heightProperty().multiply(-0.1)); line1.endXProperty().bind(text.heightProperty().multiply(0.1)); line1.endYProperty().bind(text.heightProperty().multiply(0.1)); final Line line2 = new Line(); line2.setStroke(Color.WHITE); line2.setStrokeWidth(1.7); line2.startXProperty().bind(text.heightProperty().multiply(0.1)); line2.startYProperty().bind(text.heightProperty().multiply(-0.1)); line2.endXProperty().bind(text.heightProperty().multiply(-0.1)); line2.endYProperty().bind(text.heightProperty().multiply(0.1)); final Group clear_button = new Group(circle, line1, line2); // Move clear button from center of text field to right edge clear_button.translateXProperty().bind(text.widthProperty().subtract(text.heightProperty()).divide(2.0)); // Appear as soon as text is entered clear_button.visibleProperty().bind(text.textProperty().greaterThan("")); getChildren().add(clear_button); // Clicking the button clears text clear_button.setOnMouseClicked(event -> text.setText("")); }
Example 2
Source File: CalibrationManager.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
private void createCalibrationTarget(double x, double y, double width, double height) { final RectangleRegion calibrationRectangle = new RectangleRegion(x, y, width, height); calibrationRectangle.setFill(Color.PURPLE); calibrationRectangle.setOpacity(TargetIO.DEFAULT_OPACITY); final Group calibrationGroup = new Group(); calibrationGroup.setOnMouseClicked((e) -> { calibrationGroup.requestFocus(); }); calibrationGroup.getChildren().add(calibrationRectangle); calibrationTarget = Optional.of((TargetView) calibratingCanvasManager.addTarget(null, calibrationGroup, new HashMap<String, String>(), false)); calibrationTarget.get().setKeepInBounds(true); }
Example 3
Source File: CanvasManager.java From ShootOFF with GNU General Public License v3.0 | 4 votes |
public CanvasManager(Group canvasGroup, Resetter resetter, String cameraName, ObservableList<ShotEntry> shotEntries) { this.canvasGroup = canvasGroup; config = Configuration.getConfig(); this.resetter = resetter; this.cameraName = cameraName; this.shotEntries = shotEntries; background.setOnMouseClicked((event) -> { toggleTargetSelection(Optional.empty()); }); if (Platform.isFxApplicationThread()) { progress = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); progress.setPrefHeight(config.getDisplayHeight()); progress.setPrefWidth(config.getDisplayWidth()); canvasGroup.getChildren().add(progress); canvasGroup.getChildren().add(diagnosticsVBox); diagnosticsVBox.setAlignment(Pos.CENTER); diagnosticsVBox.setFillWidth(true); diagnosticsVBox.setPrefWidth(config.getDisplayWidth()); } canvasGroup.setOnMouseClicked((event) -> { if (contextMenu.isPresent() && contextMenu.get().isShowing()) contextMenu.get().hide(); if (config.inDebugMode() && event.getButton() == MouseButton.PRIMARY) { // Click to shoot final ShotColor shotColor; if (event.isShiftDown()) { shotColor = ShotColor.RED; } else if (event.isControlDown()) { shotColor = ShotColor.GREEN; } else { return; } // Skip the camera manager for injected shots made from the // arena tab otherwise they get scaled before the call to // addArenaShot when they go through the arena camera feed's // canvas manager if (this instanceof MirroredCanvasManager) { final long shotTimestamp = System.currentTimeMillis(); addShot(new DisplayShot(new Shot(shotColor, event.getX(), event.getY(), shotTimestamp), config.getMarkerRadius()), false); } else { cameraManager.injectShot(shotColor, event.getX(), event.getY(), false); } return; } else if (contextMenu.isPresent() && event.getButton() == MouseButton.SECONDARY) { contextMenu.get().show(canvasGroup, event.getScreenX(), event.getScreenY()); } }); }