Java Code Examples for javafx.scene.input.MouseButton#SECONDARY

The following examples show how to use javafx.scene.input.MouseButton#SECONDARY . 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: ImageMaskController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
protected void singleClickedPolygonLine(MouseEvent event) {
    if (maskPolygonLine == null || !maskPolygonLine.isVisible()) {
        return;
    }

    DoublePoint p = getImageXY(event, imageView);
    if (p == null) {
        return;
    }
    if (event.getButton() == MouseButton.PRIMARY) {
        maskPolygonData.add(p.getX(), p.getY());
        drawMaskPolygonLine();

    } else if (event.getButton() == MouseButton.SECONDARY && maskPolygonData.getSize() > 2) {
        List<DoublePoint> maskPoints = maskPolygonData.getPoints();
        DoublePoint p0 = maskPoints.get(0);
        double offsetX = p.getX() - p0.getX();
        double offsetY = p.getY() - p0.getY();

        if (offsetX != 0 || offsetY != 0) {
            maskPolygonData = maskPolygonData.move(offsetX, offsetY);
            drawMaskPolygonLine();
        }
    }

}
 
Example 2
Source File: UICanvasEditor.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
/**
 This is called when the mouse listener is invoked and a mouse release was the event

 @param mousex x position of mouse relative to canvas
 @param mousey y position of mouse relative to canvas
 @param mb mouse button that was released
 */
protected void mouseReleased(int mousex, int mousey, @NotNull MouseButton mb) {
	this.mouseButtonDown = MouseButton.NONE;
	selection.setSelecting(false);
	setContextMenu(null, mousex, mousey);
	contextMenuControl = null;
	if (mb == MouseButton.SECONDARY) {
		if (menuCreator != null && selection.getFirst() != null) {
			contextMenuControl = selection.getFirst();
			setContextMenu(menuCreator.initialize(contextMenuControl.getComponent()), mousex, mousey);
		} else if (canvasContextMenu != null) {
			setContextMenu(canvasContextMenu, mousex, mousey);
		}
	} else {
		if (hasDoubleClickedCtrl) {
			doubleClickUpdateGroup.update(selection.getFirst());
		}
	}
}
 
Example 3
Source File: ResultList.java    From iliasDownloaderTool with GNU General Public License v2.0 6 votes vote down vote up
private void showContextMenu(MouseEvent event) {
	menu.hide();
	final List<IliasTreeNode> selectedNodes = ((ResultList) event.getSource())
			.getSelectionModel().getSelectedItems();
	if (selectedNodes.isEmpty() || selectedNodes == null) {
		return;
	}
	if (selectedNodes.size() == 1) {
		dashboard.getCoursesTreeView().selectFile((IliasFile) selectedNodes.get(0));
	}

	if (event.getButton() == MouseButton.SECONDARY) {
		menu = new FileContextMenu(dashboard).createMenu(selectedNodes, event);
		menu.show(this, event.getScreenX(), event.getScreenY());
	}
}
 
Example 4
Source File: EventDetectionUI.java    From SONDY with GNU General Public License v3.0 5 votes vote down vote up
public final EventHandler<MouseEvent> createSelectedEventHandler(){
    EventHandler<MouseEvent> eventHandler = new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent t) {
            AppParameters.event = (Event) eventTable.getItems().get(((TableCell)t.getSource()).getIndex());
            updateFrequencyChart();
            if(t.getButton() == MouseButton.SECONDARY){
                eventRelatedMessages();
            }
        }
    };
    return eventHandler;
}
 
Example 5
Source File: MainViewController.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Handle tree item clicked
 *
 * @param mouseEvent
 */
@FXML
public void handleTreeClicked(MouseEvent mouseEvent) {
    rightClickDevicesTreeMenu.ifPresent(ContextMenu::hide);
    CustomTreeItem selected = (CustomTreeItem) devicesTree.getSelectionModel().getSelectedItem();
    if (selected != null) {
        if (mouseEvent.getButton() == MouseButton.SECONDARY) {
            updateContextMenuState();
            rightClickDevicesTreeMenu = Optional.ofNullable(selected.getMenu());
            rightClickDevicesTreeMenu.ifPresent(contextMenu -> {
                contextMenu.show(devicesTree, mouseEvent.getScreenX(), mouseEvent.getScreenY());
            });
        }
    }
}
 
Example 6
Source File: CardAppleMouse.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
public void mousePressed(MouseEvent me) {
    MouseButton button = me.getButton();
    if (button == MouseButton.PRIMARY || button == MouseButton.MIDDLE) {
        button0press = true;
    }
    if (button == MouseButton.SECONDARY || button == MouseButton.MIDDLE) {
        button1press = true;
    }
}
 
Example 7
Source File: FXEventQueueDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public MouseButton getButtonMask() {
    if (button1Pressed) {
        return MouseButton.PRIMARY;
    }
    if (button2Pressed) {
        return MouseButton.MIDDLE;
    }
    if (button3Pressed) {
        return MouseButton.SECONDARY;
    }
    return MouseButton.NONE;
}
 
Example 8
Source File: FXEventQueueDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public MouseButton getButtons() {
    if (button1Pressed) {
        return MouseButton.PRIMARY;
    }
    if (button2Pressed) {
        return MouseButton.MIDDLE;
    }
    if (button3Pressed) {
        return MouseButton.SECONDARY;
    }
    return MouseButton.NONE;
}
 
Example 9
Source File: FXEventQueueDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void storeMouseUp(MouseButton button) {
    if (button == MouseButton.PRIMARY) {
        button1Pressed = false;
    }
    if (button == MouseButton.MIDDLE) {
        button2Pressed = false;
    }
    if (button == MouseButton.SECONDARY) {
        button3Pressed = false;
    }
}
 
Example 10
Source File: FXEventQueueDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void storeMouseDown(MouseButton button) {
    if (button == MouseButton.PRIMARY) {
        button1Pressed = true;
    }
    if (button == MouseButton.MIDDLE) {
        button2Pressed = true;
    }
    if (button == MouseButton.SECONDARY) {
        button3Pressed = true;
    }
}
 
Example 11
Source File: ClickableBitcoinAddress.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@FXML
protected void requestMoney(MouseEvent event) {
    if (event.getButton() == MouseButton.SECONDARY || (event.getButton() == MouseButton.PRIMARY && event.isMetaDown())) {
        // User right clicked or the Mac equivalent. Show the context menu.
        addressMenu.show(addressLabel, event.getScreenX(), event.getScreenY());
    } else {
        // User left clicked.
        try {
            Desktop.getDesktop().browse(URI.create(uri()));
        } catch (IOException e) {
            GuiUtils.informationalAlert("Opening wallet app failed", "Perhaps you don't have one installed?");
        }
    }
}
 
Example 12
Source File: FX.java    From FxDock with Apache License 2.0 5 votes vote down vote up
/** sometimes MouseEvent.isPopupTrigger() is not enough */
public static boolean isPopupTrigger(MouseEvent ev)
{
	if(ev.getButton() == MouseButton.SECONDARY)
	{
		if(CPlatform.isMac())
		{
			if
			(
				!ev.isAltDown() &&
				!ev.isMetaDown() &&
				!ev.isShiftDown()
			)
			{
				return true;
			}
		}
		else
		{
			if
			(
				!ev.isAltDown() &&
				!ev.isControlDown() &&
				!ev.isMetaDown() &&
				!ev.isShiftDown()
			)
			{
				return true;
			}
		}
	}
	return false;
}
 
Example 13
Source File: ImageManufacturePenController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
    @Override
    public void mouseDragged(MouseEvent event) {
        if (null == opType || imageView == null || imageView.getImage() == null) {
            return;
        }
        DoublePoint p = imageController.getImageXY(event, imageView);
        imageController.showXY(event, p);

        if (event.getButton() == MouseButton.SECONDARY || p == null) {
            return;
        }

        switch (opType) {
            case Polyline:
                if (lastX == event.getX() && lastY == event.getY()) {
                    return;
                }
                imageController.scrollPane.setPannable(false);
                imageController.maskLineData.add(p);
                lastX = event.getX();
                lastY = event.getY();
                drawPolyline();
                break;
            case DrawLines:
            case Erase:
//            case Mosaic:
//            case Frosted:
                imageController.scrollPane.setPannable(false);
                imageController.maskPenData.addPoint(p);
                lastX = event.getX();
                lastY = event.getY();
                updateMask();
        }

    }
 
Example 14
Source File: ImageManufacturePenController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
    @Override
    public void mousePressed(MouseEvent event) {
        if (null == opType || imageView == null || imageView.getImage() == null) {
            return;
        }
        DoublePoint p = imageController.getImageXY(event, imageView);
        imageController.showXY(event, p);

        if (event.getButton() == MouseButton.SECONDARY || p == null) {
            return;
        }

        switch (opType) {
            case Polyline:
                if (lastX == event.getX() && lastY == event.getY()) {
                    return;
                }
                imageController.scrollPane.setPannable(false);
                imageController.maskLineData.add(p);
                lastX = event.getX();
                lastY = event.getY();
                drawPolyline();
                break;
            case DrawLines:
            case Erase:
//            case Mosaic:
//            case Frosted:
                imageController.scrollPane.setPannable(false);
                imageController.maskPenData.startLine(p);
                lastX = event.getX();
                lastY = event.getY();
                updateMask();
        }

    }
 
Example 15
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void doubleClickedEllipse(MouseEvent event) {
    if (maskEllipseLine == null || !maskEllipseLine.isVisible()) {
        return;
    }
    DoublePoint p = getImageXY(event, imageView);
    if (p == null) {
        return;
    }
    double x = p.getX();
    double y = p.getY();
    if (event.getButton() == MouseButton.PRIMARY) {
        if (x != maskEllipseData.getCenterX()) {
            double xr = Math.abs(x - maskEllipseData.getCenterX());
            maskEllipseData = new DoubleEllipse(
                    maskEllipseData.getCenterX() - xr,
                    maskEllipseData.getCenterY() - maskEllipseData.getRadiusY(),
                    maskEllipseData.getCenterX() + xr,
                    maskEllipseData.getCenterY() + maskEllipseData.getRadiusY()
            );
            drawMaskEllipseLine();
        }

    } else if (event.getButton() == MouseButton.SECONDARY) {
        if (y != maskEllipseData.getCenterY()) {
            double yr = Math.abs(y - maskEllipseData.getCenterY());
            maskEllipseData = new DoubleEllipse(
                    maskEllipseData.getCenterX() - maskEllipseData.getRadiusX(),
                    maskEllipseData.getCenterY() - yr,
                    maskEllipseData.getCenterX() + maskEllipseData.getRadiusX(),
                    maskEllipseData.getCenterY() + yr
            );
            drawMaskEllipseLine();
        }

    }
}
 
Example 16
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void doubleClickedCircle(MouseEvent event) {
    if (maskCircleLine == null || !maskCircleLine.isVisible()) {
        return;
    }
    DoublePoint p = getImageXY(event, imageView);
    if (p == null) {
        return;
    }
    double x = p.getX();
    double y = p.getY();
    if (event.getButton() == MouseButton.PRIMARY) {

        maskCircleData.setCenterX(x);
        maskCircleData.setCenterY(y);
        drawMaskCircleLine();

    } else if (event.getButton() == MouseButton.SECONDARY) {

        if (x != maskCircleData.getCenterX() || y != maskCircleData.getCenterY()) {
            double dx = x - maskCircleData.getCenterX();
            double dy = y - maskCircleData.getCenterY();
            maskCircleData.setRadius(Math.sqrt(dx * dx + dy * dy));
            drawMaskCircleLine();
        }

    }
}
 
Example 17
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected void doubleClickedRectangle(MouseEvent event) {
    if (maskRectangleLine == null || !maskRectangleLine.isVisible()) {
        return;
    }
    DoublePoint p = getImageXY(event, imageView);
    if (p != null) {
        double x = p.getX();
        double y = p.getY();
        if (event.getButton() == MouseButton.PRIMARY) {

            if (x < maskRectangleData.getBigX() && y < maskRectangleData.getBigY()) {
                maskRectangleData.setSmallX(x);
                maskRectangleData.setSmallY(y);
                drawMaskRectangleLine();
            }

        } else if (event.getButton() == MouseButton.SECONDARY) {

            if (x > maskRectangleData.getSmallX() && y > maskRectangleData.getSmallY()) {
                maskRectangleData.setBigX(x);
                maskRectangleData.setBigY(y);
                drawMaskRectangleLine();
            }

        }
    }
}
 
Example 18
Source File: ClickableBitcoinAddress.java    From devcoretalk with GNU General Public License v2.0 5 votes vote down vote up
@FXML
protected void requestMoney(MouseEvent event) {
    if (event.getButton() == MouseButton.SECONDARY || (event.getButton() == MouseButton.PRIMARY && event.isMetaDown())) {
        // User right clicked or the Mac equivalent. Show the context menu.
        addressMenu.show(addressLabel, event.getScreenX(), event.getScreenY());
    } else {
        // User left clicked.
        try {
            Desktop.getDesktop().browse(URI.create(uri()));
        } catch (IOException e) {
            GuiUtils.informationalAlert("Opening wallet app failed", "Perhaps you don't have one installed?");
        }
    }
}
 
Example 19
Source File: DragScrollDecoration.java    From BlockMap with MIT License 4 votes vote down vote up
/** Creates an instance of this class that will drag with the right mouse button and a scroll factor of 1/10. */
public DragScrollDecoration(DisplayViewport frustum) {
	this(frustum, MouseButton.SECONDARY, 0.01d);
}
 
Example 20
Source File: InfluenceAnalysisUI.java    From SONDY with GNU General Public License v3.0 4 votes vote down vote up
public final VBox createNetworkVisualization(){
    System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
    Viewer viewer = new Viewer(AppParameters.authorNetwork, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
    view = viewer.addDefaultView(false); 
    viewer.enableAutoLayout();
    view.resizeFrame(Main.columnWidthLEFT, 290);
    swingNode = new CustomSwingNode();
    swingNode.setContent(view);
    swingNode.resize(Main.columnWidthLEFT, 290);
    EventHandler<MouseEvent> mouseHandlerGraphClick = new EventHandler<MouseEvent>() { 
        @Override 
        public void handle(MouseEvent mouseEvent) { 
            if (mouseEvent.getEventType() == MouseEvent.MOUSE_PRESSED) {
                if(mouseEvent.getButton() == MouseButton.SECONDARY){
                    Node node = (Node) view.findNodeOrSpriteAt(mouseEvent.getX(), mouseEvent.getY());
                    if(node != null){
                        userMessages(node.getId());
                    }
                }
                if(mouseEvent.getButton() == MouseButton.PRIMARY){
                    double translateCoeff = view.getCamera().getViewPercent();
                    Point3 center = view.getCamera().getViewCenter();
                    if(mouseEvent.getY()>175){
                        view.getCamera().setViewCenter(center.x, center.y-5*translateCoeff, center.z);
                    }else{
                        view.getCamera().setViewCenter(center.x, center.y+5*translateCoeff, center.z);
                    }
                    if(mouseEvent.getX()>275){
                        view.getCamera().setViewCenter(center.x+5*translateCoeff, center.y, center.z);
                    }else{
                        view.getCamera().setViewCenter(center.x-5*translateCoeff, center.y, center.z);
                    }
                }
                if(mouseEvent.getButton() == MouseButton.MIDDLE){
                    view.getCamera().setViewPercent(view.getCamera().getViewPercent()/2);
                }
            }
        }
    };   
    EventHandler<ScrollEvent> mouseHandlerGraphScroll = new EventHandler<ScrollEvent>() { 
        @Override
        public void handle(ScrollEvent event) {
            if(event.getDeltaY() < 0){
                view.getCamera().setViewPercent(view.getCamera().getViewPercent()*2);
            }else{
                view.getCamera().setViewPercent(view.getCamera().getViewPercent()/2);
            }
        }
    };   
    swingNode.setOnMousePressed(mouseHandlerGraphClick);
    swingNode.setOnScroll(mouseHandlerGraphScroll);
    VBox graphBox = new VBox();
    graphBox.getChildren().addAll(new Rectangle(Main.columnWidthLEFT,0),swingNode);
    initializeNetworkVisualizationStyle();
    return graphBox;
}