Java Code Examples for javafx.scene.input.MouseEvent#isSecondaryButtonDown()
The following examples show how to use
javafx.scene.input.MouseEvent#isSecondaryButtonDown() .
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: Fx3DStageController.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public void handleMouseDragged(MouseEvent me) { double rotateFactor = 0.12; mousePosX = me.getSceneX(); mousePosY = me.getSceneY(); if (me.isPrimaryButtonDown()) { rotateX.setAngle(rotateX.getAngle() + rotateFactor * (mousePosY - mouseOldY)); rotateY.setAngle(rotateY.getAngle() - rotateFactor * (mousePosX - mouseOldX)); } if (me.isSecondaryButtonDown()) { translateX.setX(translateX.getX() + (mousePosX - mouseOldX)); translateY.setY(translateY.getY() + (mousePosY - mouseOldY)); } mouseOldX = mousePosX; mouseOldY = mousePosY; }
Example 2
Source File: DiagramCanvasController.java From JetUML with GNU General Public License v3.0 | 6 votes |
private void mousePressed(MouseEvent pEvent) { if( pEvent.isSecondaryButtonDown() ) { aToolBar.showPopup(pEvent.getScreenX(), pEvent.getScreenY()); } else if( pEvent.getClickCount() > 1 ) { editSelected(); } else { handleSingleClick(pEvent); } Point point = getMousePoint(pEvent); aLastMousePoint = new Point(point.getX(), point.getY()); aMouseDownPoint = aLastMousePoint; aCanvas.paintPanel(); }
Example 3
Source File: Fx3DStageController.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public void handleMouseDragged(MouseEvent me) { double rotateFactor = 0.12; mousePosX = me.getSceneX(); mousePosY = me.getSceneY(); if (me.isPrimaryButtonDown()) { rotateX.setAngle(rotateX.getAngle() + rotateFactor * (mousePosY - mouseOldY)); rotateY.setAngle(rotateY.getAngle() - rotateFactor * (mousePosX - mouseOldX)); } if (me.isSecondaryButtonDown()) { translateX.setX(translateX.getX() + (mousePosX - mouseOldX)); translateY.setY(translateY.getY() + (mousePosY - mouseOldY)); } mouseOldX = mousePosX; mouseOldY = mousePosY; }
Example 4
Source File: PointerEventHandler.java From jfxvnc with Apache License 2.0 | 6 votes |
private void sendMouseEvents(MouseEvent event) { xPosProperty.set((int) Math.floor(event.getX() / zoomLevel)); yPosProperty.set((int) Math.floor(event.getY() / zoomLevel)); byte buttonMask = 0; if (event.getEventType() == MouseEvent.MOUSE_PRESSED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) { if (event.isMiddleButtonDown()) { buttonMask = 2; } else if (event.isSecondaryButtonDown()) { buttonMask = 4; } else { buttonMask = 1; } fire(new PointerEvent(buttonMask, xPosProperty.get(), yPosProperty.get())); } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED || event.getEventType() == MouseEvent.MOUSE_MOVED) { buttonMask = 0; } fire(new PointerEvent(buttonMask, xPosProperty.get(), yPosProperty.get())); }
Example 5
Source File: SlideCheckBoxBehavior.java From JFX8CustomControls with Apache License 2.0 | 6 votes |
/** * Invoked when a mouse press has occurred over the button. In addition to * potentially arming the Button, this will transfer focus to the button */ @Override public void mousePressed(MouseEvent e) { final ButtonBase button = getControl(); super.mousePressed(e); // if the button is not already focused, then request the focus if (! button.isFocused() && button.isFocusTraversable()) { button.requestFocus(); } // arm the button if it is a valid mouse event // Note there appears to be a bug where if I press and hold and release // then there is a clickCount of 0 on the release, whereas a quick click // has a release clickCount of 1. So here I'll check clickCount <= 1, // though it should really be == 1 I think. boolean valid = (e.getButton() == MouseButton.PRIMARY && ! (e.isMiddleButtonDown() || e.isSecondaryButtonDown() || e.isShiftDown() || e.isControlDown() || e.isAltDown() || e.isMetaDown())); if (! button.isArmed() && valid) { button.arm(); } }
Example 6
Source File: ViewportGestures.java From fxgraph with Do What The F*ck You Want To Public License | 5 votes |
@Override public void handle(MouseEvent event) { // right mouse button => panning if(!event.isSecondaryButtonDown()) { return; } sceneDragContext.mouseAnchorX = event.getSceneX(); sceneDragContext.mouseAnchorY = event.getSceneY(); sceneDragContext.translateAnchorX = canvas.getTranslateX(); sceneDragContext.translateAnchorY = canvas.getTranslateY(); }
Example 7
Source File: ViewportGestures.java From fxgraph with Do What The F*ck You Want To Public License | 5 votes |
@Override public void handle(MouseEvent event) { // right mouse button => panning if(!event.isSecondaryButtonDown()) { return; } canvas.setTranslateX(sceneDragContext.translateAnchorX + event.getSceneX() - sceneDragContext.mouseAnchorX); canvas.setTranslateY(sceneDragContext.translateAnchorY + event.getSceneY() - sceneDragContext.mouseAnchorY); event.consume(); }
Example 8
Source File: OSFXUtils.java From marathonv5 with Apache License 2.0 | 5 votes |
public static String mouseEventGetModifiersExText(MouseEvent event) { StringBuffer sb = new StringBuffer(); if (event.isControlDown()) { sb.append("Ctrl+"); } if (event.isMetaDown()) { sb.append("Meta+"); } if (event.isAltDown()) { sb.append("Alt+"); } if (event.isShiftDown()) { sb.append("Shift+"); } if (event.isPrimaryButtonDown()) { sb.append("Button1+"); } if (event.isMiddleButtonDown()) { sb.append("Button2+"); } if (event.isSecondaryButtonDown()) { sb.append("Button3+"); } String text = sb.toString(); if (text.equals("")) { return text; } return text.substring(0, text.length() - 1); }
Example 9
Source File: JavaFxRecorderHook.java From marathonv5 with Apache License 2.0 | 5 votes |
public static String mouseEventGetModifiersExText(MouseEvent event) { StringBuffer sb = new StringBuffer(); if (event.isControlDown()) { sb.append("Ctrl+"); } if (event.isMetaDown()) { sb.append("Meta+"); } if (event.isAltDown()) { sb.append("Alt+"); } if (event.isShiftDown()) { sb.append("Shift+"); } if (event.isPrimaryButtonDown()) { sb.append("Button1+"); } if (event.isMiddleButtonDown()) { sb.append("Button2+"); } if (event.isSecondaryButtonDown()) { sb.append("Button3+"); } String text = sb.toString(); if (text.equals("")) { return text; } return text.substring(0, text.length() - 1); }
Example 10
Source File: WolfensteinCheats.java From jace with GNU General Public License v2.0 | 5 votes |
private void processMouseEvent(MouseEvent evt) { if (evt.isPrimaryButtonDown() || evt.isSecondaryButtonDown()) { Node source = (Node) evt.getSource(); double mouseX = evt.getSceneX() / source.getBoundsInLocal().getWidth(); double mouseY = evt.getSceneY() / source.getBoundsInLocal().getHeight(); int x = Math.max(0, Math.min(7, (int) ((mouseX - 0.148) * 11))); int y = Math.max(0, Math.min(7, (int) ((mouseY - 0.101) * 11))); int location = x + (y << 3); if (evt.getButton() == MouseButton.PRIMARY) { killEnemyAt(location); } else { teleportTo(location); } } }
Example 11
Source File: JaceUIController.java From jace with GNU General Public License v2.0 | 5 votes |
private void showMenuButton(MouseEvent evt) { if (!evt.isPrimaryButtonDown() && !evt.isSecondaryButtonDown() && !controlOverlay.isVisible()) { resetMenuButtonTimer(); if (!menuButtonPane.isVisible()) { menuButtonPane.setVisible(true); FadeTransition ft = new FadeTransition(Duration.millis(500), menuButtonPane); ft.setFromValue(0.0); ft.setToValue(1.0); ft.play(); } } rootPane.requestFocus(); }
Example 12
Source File: JaceUIController.java From jace with GNU General Public License v2.0 | 5 votes |
private void showControlOverlay(MouseEvent evt) { if (!evt.isPrimaryButtonDown() && !evt.isSecondaryButtonDown()) { delayTimer.stop(); menuButtonPane.setVisible(false); controlOverlay.setVisible(true); FadeTransition ft = new FadeTransition(Duration.millis(500), controlOverlay); ft.setFromValue(0.0); ft.setToValue(1.0); ft.play(); rootPane.requestFocus(); } }
Example 13
Source File: MouseEventsHelper.java From chart-fx with Apache License 2.0 | 4 votes |
public static boolean isOnlyMiddleButtonDown(final MouseEvent event) { return event.isMiddleButtonDown() && !event.isPrimaryButtonDown() && !event.isSecondaryButtonDown(); }
Example 14
Source File: MouseEventsHelper.java From chart-fx with Apache License 2.0 | 4 votes |
public static boolean isOnlyPrimaryButtonDown(final MouseEvent event) { return event.getButton() == PRIMARY && !event.isMiddleButtonDown() && !event.isSecondaryButtonDown(); }
Example 15
Source File: Tile3D.java From scenic-view with GNU General Public License v3.0 | 4 votes |
public Tile3D(SVNode currentRoot2D, double factor2d3d, SVNode node2D, double depth, double thickness, ITile3DListener l, IThreeDOM i) { this.depth = depth; this.currentRoot2D = currentRoot2D; this.factor2d3d = factor2d3d; this.iTile3DListener = l; this.iThreeDOM = i; node2d = node2D; material = new PhongMaterial(); material.setDiffuseColor(Color.WHITE); material.setSpecularColor(Color.TRANSPARENT); Bounds bounds2D = localetoRoot(node2D); // Bounds bounds3D = new BoundingBox(bounds2D.getMinX() * factor2d3d, bounds2D.getMinY() * factor2d3d, bounds2D.getWidth() * factor2d3d, bounds2D.getHeight() * factor2d3d); super.setDepth(thickness); super.setWidth(bounds3D.getWidth()); super.setHeight(bounds3D.getHeight()); // Place object as 0,0 that is curently in the middle of 3D universe getTransforms().add(new Translate(bounds3D.getMinX() + bounds3D.getWidth() / 2, bounds3D.getMinY() + bounds3D.getHeight() / 2, 0)); setMaterial(material); snapshot(); super.setOnMouseMoved((MouseEvent me) -> { String mouseOverTileText = node2D.getImpl().getClass().getSimpleName(); iTile3DListener.onMouseMovedOnTile(mouseOverTileText); }); // super.setOnMouseClicked((MouseEvent event) -> { super.setOnMousePressed((MouseEvent event) -> { // Selection iTile3DListener.onMouseClickedOnTile(Tile3D.this); if(event.isSecondaryButtonDown()){ iTile3DListener.onMouseRightClickedOnTile(event); } }); }
Example 16
Source File: CreateCurveOnDragHandler.java From gef with Eclipse Public License 2.0 | 4 votes |
@Override public void startDrag(MouseEvent event) { // create new curve GeometricCurve curve = new GeometricCurve(new Point[] { new Point(), new Point() }, MvcLogoExample.GEF_COLOR_GREEN, MvcLogoExample.GEF_STROKE_WIDTH, MvcLogoExample.GEF_DASH_PATTERN, null); curve.addSourceAnchorage(getShapePart().getContent()); // create using CreationPolicy from root part CreationPolicy creationPolicy = getHost().getRoot().getAdapter(CreationPolicy.class); init(creationPolicy); curvePart = (GeometricCurvePart) creationPolicy.create(curve, getHost().getRoot(), HashMultimap.<IContentPart<? extends Node>, String> create()); commit(creationPolicy); // disable refresh visuals for the curvePart storeAndDisableRefreshVisuals(curvePart); // move curve to pointer location curvePart.getVisual().setEndPoint(getLocation(event)); // build operation to deselect all but the new curve part List<IContentPart<? extends Node>> toBeDeselected = new ArrayList<>( getHost().getRoot().getViewer().getAdapter(SelectionModel.class).getSelectionUnmodifiable()); toBeDeselected.remove(curvePart); DeselectOperation deselectOperation = new DeselectOperation(getHost().getRoot().getViewer(), toBeDeselected); // execute on stack try { getHost().getRoot().getViewer().getDomain().execute(deselectOperation, new NullProgressMonitor()); } catch (ExecutionException e) { throw new RuntimeException(e); } // find bend target part bendTargetPart = findBendTargetPart(curvePart, event.getTarget()); if (bendTargetPart != null) { dragPolicies = bendTargetPart.getAdapters(ClickDragGesture.ON_DRAG_POLICY_KEY); } if (dragPolicies != null) { MouseEvent dragEvent = new MouseEvent(event.getSource(), event.getTarget(), MouseEvent.MOUSE_DRAGGED, event.getX(), event.getY(), event.getScreenX(), event.getScreenY(), event.getButton(), event.getClickCount(), event.isShiftDown(), event.isControlDown(), event.isAltDown(), event.isMetaDown(), event.isPrimaryButtonDown(), event.isMiddleButtonDown(), event.isSecondaryButtonDown(), event.isSynthesized(), event.isPopupTrigger(), event.isStillSincePress(), event.getPickResult()); for (IOnDragHandler dragPolicy : dragPolicies.values()) { dragPolicy.startDrag(event); // XXX: send initial drag event so that the end position is set dragPolicy.drag(dragEvent, new Dimension()); } } }