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

The following examples show how to use javafx.scene.input.MouseButton#MIDDLE . 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: RegionBaseRepresentation.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Copy PV name to clipboard when middle button clicked
 *  @param event Mouse pressed event
 */
private void hookMiddleButtonCopy(final MouseEvent event)
{
    if (event.getButton() != MouseButton.MIDDLE)
        return;

    final String pv_name = ((PVWidget)model_widget).propPVName().getValue();

    // Copy to copy/paste clipboard
    final ClipboardContent content = new ClipboardContent();
    content.putString(pv_name);
    Clipboard.getSystemClipboard().setContent(content);

    // Copy to the 'selection' buffer used by X11
    // for middle-button copy/paste
    // Note: This is AWT API!
    // JavaFX has no API, https://bugs.openjdk.java.net/browse/JDK-8088117
    if (Toolkit.getDefaultToolkit().getSystemSelection() != null)
        Toolkit.getDefaultToolkit().getSystemSelection().setContents(new StringSelection(pv_name), null);
}
 
Example 2
Source File: IDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public MouseButton getMouseButton() {
    if (button == 0) {
        return MouseButton.PRIMARY;
    } else if (button == 1) {
        return MouseButton.MIDDLE;
    } else {
        return MouseButton.SECONDARY;
    }
}
 
Example 3
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 4
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 5
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 6
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 7
Source File: EventQueueDeviceTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected static String getModifiersExText(MouseEvent event) {
    StringBuffer buf = new StringBuffer();
    if (event.isMetaDown()) {
        buf.append("Meta");
        buf.append("+");
    }
    if (event.isControlDown()) {
        buf.append("Ctrl");
        buf.append("+");
    }
    if (event.isAltDown()) {
        buf.append("Alt");
        buf.append("+");
    }
    if (event.isShiftDown()) {
        buf.append("Shift");
        buf.append("+");
    }
    if (event.getButton() == MouseButton.PRIMARY) {
        buf.append("Button1");
        buf.append("+");
    }
    if (event.getButton() == MouseButton.MIDDLE) {
        buf.append("Button2");
        buf.append("+");
    }
    if (event.getButton() == MouseButton.SECONDARY) {
        buf.append("Button3");
        buf.append("+");
    }
    return buf.toString();
}
 
Example 8
Source File: MouseEventNotificator.java    From DeskChan with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Use this method to process a click event and send a special GUI event by the means of the message system.
 * @param event MouseEvent. A click event
 */
void notifyClickEvent(MouseEvent event) {
    if (!event.isStillSincePress()) {
        return;
    }

    Map<String, Object> m = new HashMap<>();
    m.put("screenX", event.getScreenX());
    m.put("screenY", event.getScreenY());
    m.put("nodeX", event.getScreenX() - sender.getLayoutX());
    m.put("nodeY", event.getScreenY() - sender.getLayoutY());
    m.put("nodeWidth", sender.getLayoutBounds().getWidth());
    m.put("nodeHeight", sender.getLayoutBounds().getHeight());

    StringBuilder eventMessage = new StringBuilder("gui-events:").append(senderName).append("-");
    if (event.getButton() == MouseButton.PRIMARY) {
        if (event.getClickCount() == 2) {
            eventMessage.append("double");
        } else {
            eventMessage.append("left");
        }
    } else if (event.getButton() == MouseButton.SECONDARY) {
        eventMessage.append("right");
    } else if (event.getButton() == MouseButton.MIDDLE) {
        eventMessage.append("middle");
    } else {
        return;
    }
    eventMessage.append("-click");

    Main.getInstance().getPluginProxy().sendMessage(eventMessage.toString(), m);
}
 
Example 9
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 10
Source File: CardAppleMouse.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent me) {
   MouseButton button = me.getButton();
    if (button == MouseButton.PRIMARY || button == MouseButton.MIDDLE) {
         button0press = false;
    }
    if (button == MouseButton.SECONDARY || button == MouseButton.MIDDLE) {
        button1press = false;
    }
}
 
Example 11
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;
}