Java Code Examples for javafx.scene.input.MouseEvent#MOUSE_MOVED
The following examples show how to use
javafx.scene.input.MouseEvent#MOUSE_MOVED .
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: DragResizerUtilTests.java From chart-fx with Apache License 2.0 | 6 votes |
MyMouseEvent(final double x, final double y) { super(MouseEvent.MOUSE_MOVED, x, y, // x, y, // screen coordinates MouseButton.NONE, // mouse button 0, // clickCount false, // shiftDown false, // controlDown false, // altDown false, // metaDown false, // primaryButtonDown false, // middleButtonDown false, // secondaryButtonDown true, // synthesised false, // popupTrigger true, // stillSincePress null // pickResult ); }
Example 2
Source File: DragResizerUtilTests.java From chart-fx with Apache License 2.0 | 6 votes |
MyMouseEvent(final double x, final double y, final MouseButton mouseButton, final int clickCount) { super(MouseEvent.MOUSE_MOVED, x, y, // x, y, // screen coordinates mouseButton, // mouse button clickCount, // clickCount false, // shiftDown false, // controlDown false, // altDown false, // metaDown MouseButton.PRIMARY.equals(mouseButton), // primaryButtonDown MouseButton.MIDDLE.equals(mouseButton), // middleButtonDown MouseButton.SECONDARY.equals(mouseButton), // secondaryButtonDown true, // synthesised false, // popupTrigger true, // stillSincePress null // pickResult ); }
Example 3
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 4
Source File: OverviewPanel.java From constellation with Apache License 2.0 | 5 votes |
@Override public void handle(final MouseEvent t) { if (t.getEventType() == MouseEvent.MOUSE_MOVED) { handleResizing(t); } else if (t.getEventType() == MouseEvent.MOUSE_PRESSED) { origin = t.getX(); // Set the origin on all mouse presses. handleResizing(t); } else if (t.getEventType() == MouseEvent.MOUSE_RELEASED) { handleRelease(t); } else if (t.getEventType() == MouseEvent.MOUSE_DRAGGED) { handleDragging(t); } }
Example 5
Source File: WebViewEventDispatcher.java From oim-fx with MIT License | 5 votes |
private void processMouseEvent(MouseEvent ev) { if (page == null) { return; } // RT-24511 EventType<? extends MouseEvent> type = ev.getEventType(); double x = ev.getX(); double y = ev.getY(); double screenX = ev.getScreenX(); double screenY = ev.getScreenY(); if (type == MouseEvent.MOUSE_EXITED) { type = MouseEvent.MOUSE_MOVED; x = Short.MIN_VALUE; y = Short.MIN_VALUE; Point2D screenPoint = webView.localToScreen(x, y); if (screenPoint == null) { return; } screenX = screenPoint.getX(); screenY = screenPoint.getY(); } final Integer id = idMap.get(type); if (id == null) { // not supported by webkit return; } WCMouseEvent mouseEvent = new WCMouseEvent(id, idMap.get(ev.getButton()), ev.getClickCount(), (int) x, (int) y, (int) screenX, (int) screenY, System.currentTimeMillis(), ev.isShiftDown(), ev.isControlDown(), ev.isAltDown(), ev.isMetaDown(), ev.isPopupTrigger()); page.dispatchMouseEvent(mouseEvent); ev.consume(); }
Example 6
Source File: MouseEventHandler.java From CrazyAlpha with GNU General Public License v2.0 | 5 votes |
@Override public void handle(MouseEvent event) { if (event.getEventType() == MouseEvent.MOUSE_MOVED) { BaseModel model = Game.getInstance().getModelManager().getAllModels()[0]; model.setX(event.getX()); model.setY(event.getY()); // System.out.printf("getX=%f, getY=%f\n", model.x, model.y); } }
Example 7
Source File: FXEventQueueDevice.java From marathonv5 with Apache License 2.0 | 5 votes |
@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); }
Example 8
Source File: UICanvas.java From arma-dialog-creator with MIT License | 5 votes |
@Override public void handle(MouseEvent event) { MouseButton btn = event.getButton(); if (!(event.getTarget() instanceof Canvas)) { return; } Canvas c = (Canvas) event.getTarget(); Point2D p = c.sceneToLocal(event.getSceneX(), event.getSceneY()); int mousex = (int) p.getX(); int mousey = (int) p.getY(); if (event.getEventType() == MouseEvent.MOUSE_MOVED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) { canvas.mouseMoved(mousex, mousey); canvas.setLastMousePosition(mousex, mousey); if (mouseDown) { this.canvas.requestPaint(); } } else { if (event.getEventType() == MouseEvent.MOUSE_PRESSED) { mouseDown = true; canvas.mousePressed(mousex, mousey, btn); } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) { canvas.mouseReleased(mousex, mousey, btn); mouseDown = false; canvas.requestPaint(); } } }
Example 9
Source File: CardAppleMouse.java From jace with GNU General Public License v2.0 | 5 votes |
private void processMouseEvent(MouseEvent event) { if (event.getEventType() == MouseEvent.MOUSE_MOVED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) { Node source = (Node) event.getSource(); updateLocation(event.getSceneX(), event.getSceneY(), source.getBoundsInLocal()); event.consume(); } if (event.getEventType() == MouseEvent.MOUSE_PRESSED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) { mousePressed(event); event.consume(); } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) { mouseReleased(event); event.consume(); } }
Example 10
Source File: StageFloatable.java From AnchorFX with GNU Lesser General Public License v3.0 | 4 votes |
private void setupMouseEvents() { eventsHandler = event -> { if (event.getEventType() == MouseEvent.MOUSE_PRESSED) { mousePositionStart = new Point2D(event.getScreenX(), event.getScreenY()); startWidth = getWidth(); startX = getX(); startHeight = getHeight(); startY = getY(); } if (event.getEventType() == MouseEvent.MOUSE_MOVED) { boolean sizeRight = valueInRange(event.getX(), stackPanelContainer.getWidth() - stackPanelContainer.getPadding().getLeft(), stackPanelContainer.getWidth()); boolean sizeLeft = valueInRange(event.getX(), 0, stackPanelContainer.getPadding().getRight()); boolean sizeTop = valueInRange(event.getY(), 0, stackPanelContainer.getPadding().getTop()); boolean sizeBottom = valueInRange(event.getY(), stackPanelContainer.getHeight() - stackPanelContainer.getPadding().getBottom(), stackPanelContainer.getHeight()); Cursor cursor = changeCursor(sizeLeft, sizeRight, sizeTop, sizeBottom); getScene().setCursor(cursor); } if (event.getEventType() == MouseEvent.MOUSE_DRAGGED && (getScene().getCursor() != null && getScene().getCursor() != Cursor.DEFAULT)) { if (getScene().getCursor() == Cursor.E_RESIZE || getScene().getCursor() == Cursor.SE_RESIZE || getScene().getCursor() == Cursor.NE_RESIZE) { if (event.getScreenX() - getX() + FLOATING_NODE_DROPSHADOW_RADIUS > FLOATING_NODE_MINIMUM_WIDTH) { setWidth(event.getScreenX() - getX() + FLOATING_NODE_DROPSHADOW_RADIUS); } } else if (getScene().getCursor() == Cursor.S_RESIZE || getScene().getCursor() == Cursor.SE_RESIZE || getScene().getCursor() == Cursor.SW_RESIZE) { if (event.getScreenY() - getY() + FLOATING_NODE_DROPSHADOW_RADIUS > FLOATING_NODE_MINIMUM_HEIGHT) { setHeight(event.getScreenY() - getY() + FLOATING_NODE_DROPSHADOW_RADIUS); } } else if (getScene().getCursor() == Cursor.W_RESIZE || getScene().getCursor() == Cursor.NW_RESIZE || getScene().getCursor() == Cursor.SW_RESIZE) { double newX = event.getScreenX() - FLOATING_NODE_DROPSHADOW_RADIUS; double newWidth = startX - newX + startWidth; if (newWidth > FLOATING_NODE_MINIMUM_WIDTH) { setX(newX); setWidth(newWidth); } } else if (getScene().getCursor() == Cursor.N_RESIZE || getScene().getCursor() == Cursor.NW_RESIZE || getScene().getCursor() == Cursor.NE_RESIZE) { double newY = event.getScreenY() - FLOATING_NODE_DROPSHADOW_RADIUS; double newHeight = startY - newY + startHeight; if (newHeight > FLOATING_NODE_MINIMUM_HEIGHT) { setY(newY); setHeight(newHeight); } } } /* else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) { // TODO: handle this event? } */ }; stackPanelContainer.addEventFilter(MouseEvent.MOUSE_PRESSED, eventsHandler); stackPanelContainer.addEventFilter(MouseEvent.MOUSE_MOVED, eventsHandler); stackPanelContainer.addEventFilter(MouseEvent.MOUSE_DRAGGED, eventsHandler); stackPanelContainer.addEventFilter(MouseEvent.MOUSE_RELEASED, eventsHandler); }
Example 11
Source File: CameraController.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
private void handleMouseEvent(MouseEvent t) { if (t.getEventType() == MouseEvent.MOUSE_PRESSED) { switch (t.getButton()) { case PRIMARY: handlePrimaryMousePress(t); break; case MIDDLE: handleMiddleMousePress(t); break; case SECONDARY: handleSecondaryMousePress(t); break; default: throw new AssertionError(); } handleMousePress(t); } else if (t.getEventType() == MouseEvent.MOUSE_DRAGGED) { Point2D d = getMouseDelta(t); switch (t.getButton()) { case PRIMARY: handlePrimaryMouseDrag(t, d, speed); break; case MIDDLE: handleMiddleMouseDrag(t, d, speed); break; case SECONDARY: handleSecondaryMouseDrag(t, d, speed); break; default: throw new AssertionError(); } } else if (t.getEventType() == MouseEvent.MOUSE_MOVED) { handleMouseMoved(t, getMouseDelta(t), speed); } else if (t.getEventType() == MouseEvent.MOUSE_CLICKED) { switch (t.getButton()) { case PRIMARY: handlePrimaryMouseClick(t); break; case MIDDLE: handleMiddleMouseClick(t); break; case SECONDARY: handleSecondaryMouseClick(t); break; default: throw new AssertionError(); } } }