Java 类javafx.scene.input.MouseButton 实例源码

项目:Suji    文件:Scoring.java   
@Override
public void canvasClicked(MouseEvent mouseEvent) {
    DrawCoords mousePosition = new DrawCoords(mouseEvent.getX(), mouseEvent.getY());
    CoordProjector projector = getProjector(boardCanvas);
    Coords boardPos = projector.nearestCoords(mousePosition);

    if ( !projector.isWithinBounds(mousePosition) )
        return;

    scorePane.enableButtons();
    if ( mouseEvent.getButton() == MouseButton.PRIMARY ) {
        if ( !mouseEvent.isShiftDown() )
            boardScorer.markGroupDead(boardPos);
        else
            boardScorer.unmarkGroupDead(boardPos);
    }
}
项目:marathonv5    文件:MarathonFileChooser.java   
public ChildrenFileCell() {
    addEventFilter(MouseEvent.MOUSE_CLICKED, (e) -> {
        if (fileChooserInfo.isFileCreation()) {
            return;
        }
        if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 1) {
            return;
        }
        File selectedItem = childrenListView.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            fileNameBox.clear();
            fileNameBox.setText(selectedItem.getName());
        } else {
            fileNameBox.clear();
        }

    });
}
项目:fx-animation-editor    文件:DragBehavior.java   
private void onMousePressed(MouseEvent event) {
    // Don't start drag if shortcut is down because the node might be about to be deselected.
    if (event.getButton() == MouseButton.PRIMARY && !event.isShortcutDown()) {
        screenXAtPress = event.getScreenX();
        screenYAtPress = event.getScreenY();
        lastScreenX = screenXAtPress;
        lastScreenY = screenYAtPress;
        panXAtPress = panningComponent.panXProperty().get();
        panYAtPress = panningComponent.panYProperty().get();
        xAtPress = node.getLayoutX();
        yAtPress = node.getLayoutY();
        dragActive = true;
        inertiaOvercome = false;
        if (onDragStarted != null) {
            onDragStarted.run();
        }
        event.consume();
    }
}
项目:fx-animation-editor    文件:KeyFrameDragAnimator.java   
private void onPressed(Node dragged, MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
        dragActive = true;
        inertiaOvercome = false;
        nodeXOnPress = dragged.getLayoutX();
        mouseXOnPress = event.getScreenX();

        minWidthBackup = container.getMinWidth();
        prefWidthBackup = container.getPrefWidth();
        maxWidthBackup = container.getMaxWidth();
        container.setMinWidth(container.getWidth());
        container.setPrefWidth(container.getWidth());
        container.setMaxWidth(container.getWidth());

        translates = moveableChildren().collect(Collectors.toMap(Function.identity(), child -> new TranslateAnimation(child, dragged)));
        moveableChildren().forEach(child -> child.setManaged(false));

        // Move dragged node temporarily to front. Reset to original index on mouse release.
        dragged.toFront();
    }
}
项目:marathonv5    文件:RFXHyperlinkButtonTest.java   
@Test public void click() {
    Hyperlink button = (Hyperlink) getPrimaryStage().getScene().getRoot().lookup(".hyperlink");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("click", select.getCall());
    AssertJUnit.assertEquals("", select.getParameters()[0]);
}
项目:xbrowser    文件:MouseEventHandler.java   
@Override
public void handle(MouseEvent event) {
    if(event.getEventType()==MouseEvent.MOUSE_MOVED){
        move.handle(event.getX(),event.getY());
    }else if(event.getEventType()==MouseEvent.MOUSE_PRESSED){
        if(event.getButton()==MouseButton.PRIMARY){
            press.handle(event.getX(),event.getY());
        }else if(event.getButton()==MouseButton.SECONDARY){
            rightPress.handle(event.getX(),event.getY());
        }
    }else if(event.getEventType()==MouseEvent.MOUSE_RELEASED){
        if(event.getButton()==MouseButton.PRIMARY){
            release.handle(event.getX(),event.getY());
        }else if(event.getButton()==MouseButton.SECONDARY){
            rightRelease.handle(event.getX(),event.getY());
        }
    }
}
项目:marathonv5    文件:RFXButtonBaseTest.java   
@Test public void getText() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
            text.add(rfxButtonBase.getAttribute("text"));
        }
    });
    new Wait("Waiting for button text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Color", text.get(0));
}
项目:gen7-iv-calculator    文件:OutputPresenter.java   
public void changeHiddenPower(Event event) {
    if (event instanceof MouseEvent) {
        MouseEvent mouseEvent = (MouseEvent) event;
        MouseButton mouseButton = mouseEvent.getButton();
        if (mouseEvent.isShiftDown() || mouseButton.equals(MouseButton.SECONDARY)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToNext());
        } else if (mouseButton.equals(MouseButton.PRIMARY)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToPrevious());
        } else if (mouseButton.equals(MouseButton.MIDDLE)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.setUnknown());
        }
    } else if (event instanceof ScrollEvent) {
        double delta = ((ScrollEvent) event).getDeltaY();
        if (delta > 0) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToNext());
        } else if (delta < 0) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToPrevious());
        }
    }
}
项目:WebPLP    文件:Main.java   
private ConsolePane createConsole()
{
    ConsolePane console = new ConsolePane();
    ContextMenu contextMenu = new ContextMenu();

    MenuItem clearConsoleItem = new MenuItem("Clear");
    clearConsoleItem.setOnAction(e -> console.clear());
    contextMenu.getItems().add(clearConsoleItem);

    console.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
        contextMenu.show(console, event.getScreenX(), event.getScreenY());
        event.consume();
    });
    console.setOnMouseClicked(event -> {
        if (event.getButton() == MouseButton.PRIMARY)
            contextMenu.hide();
    });

    return console;
}
项目:CalendarFX    文件:CreateDeleteHandler.java   
private void createEntry(MouseEvent evt) {
    if (evt.getButton().equals(MouseButton.PRIMARY) && evt.getClickCount() == 2) {
        LoggingDomain.VIEW.fine("create entry mouse event received inside control: " + dateControl.getClass().getSimpleName());

        ZonedDateTime time = ZonedDateTime.now();
        if (dateControl instanceof ZonedDateTimeProvider) {
            ZonedDateTimeProvider provider = (ZonedDateTimeProvider) dateControl;
            time = provider.getZonedDateTimeAt(evt.getX(), evt.getY());
        }

        Optional<Calendar> calendar = dateControl.getCalendarAt(evt.getX(), evt.getY());

        if (time != null) {
            dateControl.createEntryAt(time, calendar.orElse(null));
        }
    }
}
项目:CalendarFX    文件:DayViewEditController.java   
private void mouseReleased(MouseEvent evt) {
    if (!evt.getButton().equals(MouseButton.PRIMARY) || dayEntryView == null || dragMode == null || !dragging) {
        return;
    }
    dragging = false;

    Calendar calendar = entry.getCalendar();
    if (calendar.isReadOnly()) {
        return;
    }

    dayEntryView.getProperties().put("dragged", false); //$NON-NLS-1$
    dayEntryView.getProperties().put("dragged-start", false); //$NON-NLS-1$
    dayEntryView.getProperties().put("dragged-end", false); //$NON-NLS-1$

    /*
     * We might run in the sampler application. Then the entry view will not
     * be inside a date control.
     */
    DraggedEntry draggedEntry = dayView.getDraggedEntry();

    if (draggedEntry != null) {
        entry.setInterval(draggedEntry.getInterval());
        dayView.setDraggedEntry(null);
    }
}
项目:FX-Test    文件:Drag.java   
/**
 * Create an operation dragging from an absolute position to a relative position
 * from there
 * 
 * @param d
 *            the duration
 * @param fromX
 *            the start x coordinate on screen
 * @param fromY
 *            the start y coordinate on screen
 * @param dx
 *            delta of the x coordinate
 * @param dy
 *            delta of the y coordinate
 * @return the operation
 */
public static Operation by(Duration d, double fromX, double fromY, double dx, double dy) {
    return (r) -> {
        r.mouseMoveTo((int) fromX, (int) fromY);
        r.press(MouseButton.PRIMARY);
        BlockCondition<Void> b = new BlockCondition<>();
        Transition tt = new Transition() {
            {
                setCycleDuration(javafx.util.Duration.millis(d.toMillis()));
            }

            @Override
            protected void interpolate(double frac) {
                r.mouseMoveTo((int) (fromX + dx * frac), (int) (fromY + dy * frac));
            }
        };
        tt.setOnFinished(e -> b.release(null));
        tt.play();
        r.block(b);
        r.release(MouseButton.PRIMARY);
        return r;
    };
}
项目:fx-animation-editor    文件:SelectionBoxComponent.java   
private void onBackgroundDragged(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && dragActive) {
        double x = event.getX() - panningComponent.panXProperty().get();
        double y = event.getY() - panningComponent.panYProperty().get();

        double minX = Math.min(x, xAtPress);
        double minY = Math.min(y, yAtPress);
        double maxX = Math.max(x, xAtPress);
        double maxY = Math.max(y, yAtPress);

        root.setVisible(true);
        root.setLayoutX(minX);
        root.setLayoutY(minY);
        root.setWidth(maxX - minX);
        root.setHeight(maxY - minY);
    }
}
项目:dragdropfx    文件:TextDragListenerContext.java   
private EventHandler<MouseEvent> makeOnButtonDownListener(){
    return new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            if(event.getButton() == MouseButton.PRIMARY){
                HitInfo i = DnDTextInput.getHitInfo((TextInputControl) event.getSource(), event);
                IndexRange r = textInput.getSelection();

                if(DnDTextInput.isInRange(i.getInsertionIndex(), r)){
                    currentSelection = r;
                }

                inClick = true;
            }
        }
    };
}
项目:GestureFX    文件:GesturePaneTest.java   
@Test
public void testDragAndDrop() throws Exception {
    pane.zoomTo(2, pane.targetPointAtViewportCentre());
    Transform expected = target.captureTransform();
    FxRobot robot = new FxRobot();
    robot.moveTo(pane)
            .drag(MouseButton.PRIMARY).dropBy(100, 100);
    Transform actual = target.captureTransform();
    assertThat(actual).isEqualToComparingOnlyGivenFields(expected,
            "xx", "xy", "xz",
            "yx", "yy", "yz",
            "zx", "zy", "zz",
            /* "xt", "yt", */ "zt"); // x y will have delta
    assertThat(actual.getTx()).isCloseTo(expected.getTx() + 100, Offset.offset(10d));
    assertThat(actual.getTy()).isCloseTo(expected.getTy() + 100, Offset.offset(10d));
}
项目:GestureFX    文件:GesturePaneTest.java   
@Test
public void testGestureDisabling() throws Exception {
    pane.setGestureEnabled(false);
    pane.zoomTo(2, pane.targetPointAtViewportCentre());
    Transform expected = target.captureTransform();
    FxRobot robot = new FxRobot();
    robot.moveTo(pane)
            .scroll(2, VerticalDirection.UP)
            .scroll(2, VerticalDirection.DOWN)
            .drag(MouseButton.PRIMARY).dropBy(100, 100);
    assertThat(target.captureTransform()).isEqualToComparingOnlyGivenFields(expected,
            "xx", "xy", "xz",
            "yx", "yy", "yz",
            "zx", "zy", "zz",
            "xt", "yt", "zt");
}
项目:voogasalad-ltub    文件:View.java   
private void initHandlers() {
    gameWorldCanvas.setOnMouseClicked(e -> {
        ViewPoint viewPos = new ViewPoint(e.getX(), e.getY());
        if (e.getButton() == MouseButton.PRIMARY) {
            bus.emit(new MouseEvent(MouseEvent.LEFT, camera.viewToGame(viewPos)));
        } else if (e.getButton() == MouseButton.SECONDARY) {
            bus.emit(new MouseEvent(MouseEvent.RIGHT, camera.viewToGame(viewPos)));
        }
    });
    gameWorldCanvas.setOnScroll((e) -> {
        // for my mouse, each scroll is 40 pixels
        // e.getDeltaY() is negative when scroll down (zoom in, increase zoom factor)
        bus.emit(new CameraEvent(CameraEvent.ZOOM, e.getDeltaY() / 400));
    });
    scene.setOnKeyPressed(e -> {
        bus.emit(new KeyEvent(KeyEvent.PRESS, e.getCode()));
    });
    scene.setOnKeyReleased(e -> {
        bus.emit(new KeyEvent(KeyEvent.RELEASE, e.getCode()));
    });
    scene.setOnKeyTyped(e -> {
        bus.emit(new KeyEvent(KeyEvent.TYPE, e.getCode()));
    });
}
项目:jmonkeybuilder    文件:AbstractSceneEditor3DState.java   
@Override
@JMEThread
protected void onActionImpl(@NotNull final String name, final boolean isPressed, final float tpf) {
    super.onActionImpl(name, isPressed, tpf);
    if (MOUSE_RIGHT_CLICK.equals(name)) {
        if(isEditingMode()) {
            if (isPressed) startEditing(getEditingInput(MouseButton.SECONDARY));
            else finishEditing(getEditingInput(MouseButton.SECONDARY));
        } else if(!isPressed) {
            processSelect();
        }
    } else if (MOUSE_LEFT_CLICK.equals(name)) {
        if(isEditingMode()) {
            if (isPressed) startEditing(getEditingInput(MouseButton.PRIMARY));
            else finishEditing(getEditingInput(MouseButton.PRIMARY));
        } else {
            if (isPressed) startTransform();
            else endTransform();
        }
    }
}
项目:jmonkeybuilder    文件:AbstractSceneEditor3DState.java   
/**
 * Gets editing input.
 *
 * @param mouseButton the mouse button
 * @return the editing input
 */
@FromAnyThread
protected @NotNull EditingInput getEditingInput(final MouseButton mouseButton) {
    switch (mouseButton) {
        case SECONDARY: {

            if(isControlDown()) {
                return EditingInput.MOUSE_SECONDARY_WITH_CTRL;
            }

            return EditingInput.MOUSE_SECONDARY;
        }
        case PRIMARY: {
            return EditingInput.MOUSE_PRIMARY;
        }
    }

    return EditingInput.MOUSE_PRIMARY;
}
项目:Gleisbelegung    文件:Gleis.java   
public void setGleisLabel(LabelContainer gleisLabel) {
    gleisLabel.getLabel().setOnMouseClicked(e -> {
        if(e.getButton() == MouseButton.PRIMARY){
            hebeHervor();
        } else if(e.getButton() == MouseButton.SECONDARY){
            aendereReihenfolge();
        }
    });

    this.gleisLabel = gleisLabel;
}
项目:marathonv5    文件:IDevice.java   
public MouseButton getMouseButton() {
    if (button == 0) {
        return MouseButton.PRIMARY;
    } else if (button == 1) {
        return MouseButton.MIDDLE;
    } else {
        return MouseButton.SECONDARY;
    }
}
项目:marathonv5    文件:FXEventQueueDevice.java   
private void storeMouseDown(MouseButton button) {
    if (button == MouseButton.PRIMARY) {
        button1Pressed = true;
    }
    if (button == MouseButton.MIDDLE) {
        button2Pressed = true;
    }
    if (button == MouseButton.SECONDARY) {
        button3Pressed = true;
    }
}
项目:marathonv5    文件:FXEventQueueDevice.java   
private void storeMouseUp(MouseButton button) {
    if (button == MouseButton.PRIMARY) {
        button1Pressed = false;
    }
    if (button == MouseButton.MIDDLE) {
        button2Pressed = false;
    }
    if (button == MouseButton.SECONDARY) {
        button3Pressed = false;
    }
}
项目:marathonv5    文件:FXEventQueueDevice.java   
public MouseButton getButtons() {
    if (button1Pressed) {
        return MouseButton.PRIMARY;
    }
    if (button2Pressed) {
        return MouseButton.MIDDLE;
    }
    if (button3Pressed) {
        return MouseButton.SECONDARY;
    }
    return MouseButton.NONE;
}
项目:marathonv5    文件:FXEventQueueDevice.java   
public MouseButton getButtonMask() {
    if (button1Pressed) {
        return MouseButton.PRIMARY;
    }
    if (button2Pressed) {
        return MouseButton.MIDDLE;
    }
    if (button3Pressed) {
        return MouseButton.SECONDARY;
    }
    return MouseButton.NONE;
}
项目:marathonv5    文件:FXEventQueueDevice.java   
@Override public void buttonDown(Node node, Buttons button, double xoffset, double yoffset) {
    MouseButton mb = button.getMouseButton();
    dispatchEvent(createMouseEvent(MouseEvent.MOUSE_PRESSED, null, null, xoffset, yoffset, 0, 0, mb, 1,
            deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed, true, false,
            false, false, false, false, node));
    deviceState.storeMouseDown(mb);
    deviceState.setDragSource(node);
}
项目:marathonv5    文件:FXEventQueueDevice.java   
@Override public void buttonUp(Node node, Buttons button, double xoffset, double yoffset) {
    MouseButton mb = button.getMouseButton();
    dispatchEvent(createMouseEvent(MouseEvent.MOUSE_RELEASED, null, null, xoffset, yoffset, 0, 0, mb, 1,
            deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed, true, false,
            false, false, false, false, node));
    deviceState.storeMouseUp(mb);
    deviceState.setDragSource(null);
}
项目:marathonv5    文件:FXEventQueueDevice.java   
@Override public void moveto(Node node, double xoffset, double yoffset) {
    MouseButton buttons = deviceState.getButtons();
    if (node != deviceState.getNode()) {
        if (deviceState.getNode() != null) {
            dispatchEvent(createMouseEvent(MouseEvent.MOUSE_PRESSED, null, null, xoffset, yoffset, 0, 0, buttons, 0,
                    deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                    buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                    false, false, node));
        }
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_ENTERED, null, null, xoffset, yoffset, 0, 0, buttons, 0,
                deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false, false,
                false, node));
    }
    Node source = node;
    EventType<MouseEvent> id = MouseEvent.MOUSE_MOVED;
    if (buttons != MouseButton.NONE) {
        id = MouseEvent.MOUSE_DRAGGED;
        source = deviceState.getDragSource();
    }
    MouseButton modifierEx = deviceState.getButtonMask();
    dispatchEvent(createMouseEvent(id, null, null, xoffset, yoffset, 0, 0, buttons, 0, deviceState.shiftPressed,
            deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed, modifierEx == MouseButton.PRIMARY,
            modifierEx == MouseButton.MIDDLE, modifierEx == MouseButton.SECONDARY, false, false, false, source));
    deviceState.setNode(node);
    deviceState.setMousePosition(xoffset, yoffset);
}
项目:marathonv5    文件:FXEventQueueDevice.java   
private void dispatchMouseEvent(Node node, Node target, PickResult pickResult, boolean popupTrigger, int clickCount,
        MouseButton buttons, double x, double y) {
    ensureVisible(node);
    Point2D screenXY = node.localToScreen(new Point2D(x, y));
    if (node != deviceState.getNode()) {
        if (deviceState.getNode() != null) {
            dispatchEvent(createMouseEvent(MouseEvent.MOUSE_EXITED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                    buttons, clickCount, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed,
                    deviceState.metaPressed, false, false, false, false, popupTrigger, false, node));
        }
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_ENTERED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, clickCount, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed,
                deviceState.metaPressed, false, false, false, false, popupTrigger, false, node));
    }
    for (int n = 1; n <= clickCount; n++) {
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_PRESSED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                popupTrigger, false, node));
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_RELEASED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                popupTrigger, false, node));
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_CLICKED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                popupTrigger, false, node));
    }
}
项目:marathonv5    文件:EventQueueDeviceTest.java   
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();
}
项目:marathonv5    文件:WSRecorder.java   
@Override public void recordClick2(final RFXComponent r, MouseEvent e, boolean withCellInfo) {
    final JSONObject event = new JSONObject();
    event.put("type", "click");
    int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
    event.put("button", button);
    event.put("clickCount", e.getClickCount());
    event.put("modifiersEx", buildModifiersText(e));
    double x = e.getX();
    double y = e.getY();
    Node source = (Node) e.getSource();
    Node target = r.getComponent();
    Point2D sts = source.localToScreen(new Point2D(0, 0));
    Point2D tts = target.localToScreen(new Point2D(0, 0));
    x = e.getX() - tts.getX() + sts.getX();
    y = e.getY() - tts.getY() + sts.getY();
    event.put("x", x);
    event.put("y", y);
    if (withCellInfo) {
        event.put("cellinfo", r.getCellInfo());
    }
    final JSONObject o = new JSONObject();
    o.put("event", event);
    fill(r, o);
    if (e.getClickCount() == 1) {
        clickTimer = new Timer();
        clickTimer.schedule(new TimerTask() {
            @Override public void run() {
                sendRecordMessage(o);
            }
        }, timerinterval.intValue());
    } else if (e.getClickCount() == 2) {
        if (clickTimer != null) {
            clickTimer.cancel();
            clickTimer = null;
        }
        sendRecordMessage(o);
    }
}
项目:fx-animation-editor    文件:KeyFrameDragAnimator.java   
private void onReleased(Node dragged, MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && dragActive) {
        dragActive = false;

        container.setMinWidth(minWidthBackup);
        container.setPrefWidth(prefWidthBackup);
        container.setMaxWidth(maxWidthBackup);

        int draggedIndex = translates.get(dragged).initialIndex;
        int dropIndex = translates.values().stream()
                .filter(t -> t.forward.get())
                .map(t -> t.initialIndex)
                .map(i -> i < draggedIndex ? i : i - 1)
                .min(Comparator.naturalOrder())
                .orElse(container.getChildren().size() - 1);

        // Reset dragged node to original index.
        for (int i = draggedIndex; i < container.getChildren().size() - 1; i++) {
            container.getChildren().get(draggedIndex).toFront();
        }

        moveableChildren().forEach(child -> child.setManaged(true));
        moveableChildren().forEach(child -> child.setTranslateX(0));
        translates.values().forEach(animation -> {
            if (animation.translate != null) {
                animation.translate.stop();
                animation.translate.setNode(null);
            }
        });
        translates = null;

        if (repositionHandler != null && draggedIndex != dropIndex) {
            repositionHandler.accept(draggedIndex, dropIndex);
        }
    }
}
项目:fx-animation-editor    文件:SelectionBoxComponent.java   
private void onBackgroundReleased(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
        root.setVisible(false);
        dragActive = false;
        if (!event.isStillSincePress()) {
            selectInBounds(root.getBoundsInParent());
        }
        root.setWidth(0);
        root.setHeight(0);
    }
}
项目:GameAuthoringEnvironment    文件:OnScreenSprite.java   
/**
 * Sets the sprite action menu on right click
 *
 * @param node
 */
private void createRightClickMenu (Node node) {
    node.setOnMouseClicked(event -> {
        if (event.getButton() == MouseButton.SECONDARY) {
            spriteActionsMenu(levelView.getPane()).show(node,
                                                        event.getScreenX(),
                                                        event.getScreenY());
        }
    });
}
项目:GameAuthoringEnvironment    文件:SceneCreator.java   
/**
 * Handles mouse click actions for the scene
 *
 * @param e
 */
private void handleMouseClick (MouseEvent e) {
    if (e.getButton() == MouseButton.PRIMARY && e.getClickCount() == DOUBLE_CLICK) {
        myController.uploadNewBackground();
        myRenderer.updateNewTiles();
        updateBitMap();
        render();
    }
}
项目:fxutils    文件:FXEvent.java   
/**
 * Convenience setter for double-click events. The handler that you pass to this function doesn't have to 
 * explicitly check that the event is a double click (that's the convenience).
 * 
 * @param node Node that will respond to a double-click
 * @param doubleClickHandler Your double-click handler.
 */
public static void setOnDoubleClick(Node node, EventHandler<? super MouseEvent> doubleClickHandler) {
    node.setOnMouseClicked(event -> {
        if(event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2) {
            doubleClickHandler.handle(event);
        }
    });
}
项目:UDE    文件:BackgroundMngrController.java   
public void newDir2() {
    int j = 0; // Used to properly insert to grid when there are files other than an image
    for (int i=0; i<fileList.length; i++) {
        String path = "" + fileList[i];
        if (fileList[i].getName().contains(".png") || fileList[i].getName().contains(".jpg")||
            fileList[i].getName().contains(".gif") || fileList[i].getName().contains(".jpeg")) {
            String title = "" + fileList[i];
            pth = new Image("file://" + fileList[i]);
            ImageView view = (ImageView) (tilePane.getChildren().get(j));

            view.setImage(pth);
            view.setCache(true);
                                    final ImageView imgViewPoped =  new ImageView("file://" + fileList[i]);
            // image click actions
            view.setOnMouseClicked(mouse -> {
                MouseButton button = mouse.getButton();
                            if (mouse.getClickCount() == 2 && button == MouseButton.PRIMARY && !mouse.isConsumed()) {
                                mouse.consume();
                    txtDirPath.setText(path);
                    settings.setBackgroundInfo(path);
                                     } else if (button == MouseButton.SECONDARY) {
                             displayImg(imgViewPoped, title);
                }
            });
            j++;
                    } else {
               System.out.println("Not an image file.");
        }
    }
}
项目:creacoinj    文件:ClickableBitcoinAddress.java   
@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?");
        }
    }
}
项目:shuffleboard    文件:MainWindowControllerTest.java   
@Test
public void testDragSingleNetworkTableSourceToWidgetPane() {
  NetworkTableInstance inst = NetworkTableInstance.getDefault();
  inst.getEntry("/a string source").setString("foo");
  inst.waitForEntryListenerQueue(-1.0);
  WaitForAsyncUtils.waitForFxEvents();

  drag(NodeMatchers.hasText("a string source"), MouseButton.PRIMARY)
      .dropTo(".widget-pane");

  WidgetTile tile = lookup(".widget-pane .tile").query();
  assertNotNull(tile);
}
项目:CalendarFX    文件:WeekDayHeaderView.java   
/**
 * Constructs a new date cell.
 */
public WeekDayCell(WeekDayHeaderView view) {
    Objects.requireNonNull(view);
    getStyleClass().add("cell"); //$NON-NLS-1$
    setMaxWidth(Double.MAX_VALUE);
    dateProperty().addListener(it -> setText(formatter.format(getDate())));
    if (view.isEnableHyperlinks()) {
        getStyleClass().add("date-hyperlink");
        setOnMouseClicked(evt -> {
            if (evt.getButton() == MouseButton.PRIMARY && evt.getClickCount() == 1) {
                fireEvent(new RequestEvent(this, this, getDate()));
            }
        });
    }
}