javafx.scene.input.PickResult Java Examples
The following examples show how to use
javafx.scene.input.PickResult.
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: RFXButtonBaseTest.java From marathonv5 with Apache License 2.0 | 7 votes |
@Test public void click() { Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button"); 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]); }
Example #2
Source File: DockEvent.java From DockFX with GNU Lesser General Public License v3.0 | 6 votes |
/** * Constructs new DockEvent event.. * * @param source the source of the event. Can be null. * @param target the target of the event. Can be null. * @param eventType The type of the event. * @param x The x with respect to the source. Should be in scene coordinates if source == null or * source is not a Node. * @param y The y with respect to the source. Should be in scene coordinates if source == null or * source is not a Node. * @param screenX The x coordinate relative to screen. * @param screenY The y coordinate relative to screen. * @param pickResult pick result. Can be null, in this case a 2D pick result without any further * values is constructed based on the scene coordinates * @param contents The contents being dragged during this event. */ public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType, double x, double y, double screenX, double screenY, PickResult pickResult, Node contents) { super(source, target, eventType); this.x = x; this.y = y; this.screenX = screenX; this.screenY = screenY; this.sceneX = x; this.sceneY = y; this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y); final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null); this.x = p.getX(); this.y = p.getY(); this.z = p.getZ(); this.contents = contents; }
Example #3
Source File: FXNonApplicationThreadRule.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Fires a newly created {@link MouseEvent} of type * {@link MouseEvent#MOUSE_RELEASED} to the target {@link Node} of the last * mouse interaction. * * @param mods * The {@link Modifiers} for the {@link MouseEvent}. */ public void mouseRelease(final Modifiers mods) { waitForIdle(); run(() -> { Point2D local = lastMouseInteraction.target.sceneToLocal(lastMouseInteraction.sceneX, lastMouseInteraction.sceneY); Point2D screen = lastMouseInteraction.target.localToScreen(local.getX(), local.getY()); fireEvent(lastMouseInteraction.target, new MouseEvent(lastMouseInteraction.target, lastMouseInteraction.target, MouseEvent.MOUSE_RELEASED, local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.PRIMARY, 1, mods.shift, mods.control, mods.alt, mods.meta, false, false, false, false, false, false, new PickResult(lastMouseInteraction.target, lastMouseInteraction.sceneX, lastMouseInteraction.sceneY))); }); waitForIdle(); }
Example #4
Source File: FXNonApplicationThreadRule.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Fires a newly created {@link MouseEvent} of type * {@link MouseEvent#MOUSE_PRESSED} to the target {@link Node} of the last mouse * interaction. * * @param mods * The {@link Modifiers} for the {@link MouseEvent}. */ public void mousePress(final Modifiers mods) { waitForIdle(); run(() -> { Point2D local = lastMouseInteraction.target.sceneToLocal(lastMouseInteraction.sceneX, lastMouseInteraction.sceneY); Point2D screen = lastMouseInteraction.target.localToScreen(local.getX(), local.getY()); fireEvent(lastMouseInteraction.target, new MouseEvent(lastMouseInteraction.target, lastMouseInteraction.target, MouseEvent.MOUSE_PRESSED, local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.PRIMARY, 1, mods.shift, mods.control, mods.alt, mods.meta, true, false, false, false, false, false, new PickResult(lastMouseInteraction.target, lastMouseInteraction.sceneX, lastMouseInteraction.sceneY))); }); waitForIdle(); }
Example #5
Source File: FXNonApplicationThreadRule.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Fires a newly created {@link MouseEvent} of type * {@link MouseEvent#MOUSE_MOVED} to the given target {@link Node}. * * @param sceneX * The final x-coordinate (in scene) for the drag. * @param sceneY * The final y-coordinate (in scene) for the drag. * @param mods * The {@link Modifiers} for the {@link MouseEvent}. */ public void mouseMove(final Node target, final double sceneX, final double sceneY, final Modifiers mods) { waitForIdle(); // save mouse interaction data lastMouseInteraction = new MouseInteraction(); lastMouseInteraction.target = target; lastMouseInteraction.sceneX = sceneX; lastMouseInteraction.sceneY = sceneY; run(() -> { Point2D local = target.sceneToLocal(sceneX, sceneY); Point2D screen = target.localToScreen(local.getX(), local.getY()); fireEvent(target, new MouseEvent(target, target, MouseEvent.MOUSE_MOVED, local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.NONE, 0, mods.shift, mods.control, mods.alt, mods.meta, false, false, false, false, false, false, new PickResult(target, sceneX, sceneY))); }); waitForIdle(); }
Example #6
Source File: FXNonApplicationThreadRule.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Fires a newly created {@link MouseEvent} of type * {@link MouseEvent#MOUSE_DRAGGED} to the target {@link Node} of the last mouse * interaction. * * @param sceneX * The final x-coordinate (in scene) for the drag. * @param sceneY * The final y-coordinate (in scene) for the drag. * @param mods * The {@link Modifiers} for the {@link MouseEvent}. */ public void mouseDrag(final double sceneX, final double sceneY, final Modifiers mods) { waitForIdle(); // save mouse interaction data lastMouseInteraction.sceneX = sceneX; lastMouseInteraction.sceneY = sceneY; run(() -> { Point2D local = lastMouseInteraction.target.sceneToLocal(sceneX, sceneY); Point2D screen = lastMouseInteraction.target.localToScreen(local.getX(), local.getY()); fireEvent(lastMouseInteraction.target, new MouseEvent(lastMouseInteraction.target, lastMouseInteraction.target, MouseEvent.MOUSE_DRAGGED, local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.PRIMARY, 0, mods.shift, mods.control, mods.alt, mods.meta, true, false, false, false, false, false, new PickResult(lastMouseInteraction.target, sceneX, sceneY))); }); waitForIdle(); }
Example #7
Source File: RFXButtonBaseTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@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)); }
Example #8
Source File: RFXHyperlinkButtonTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@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]); }
Example #9
Source File: JavaFXTreeTableViewCellElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { Node cell = getPseudoComponent(); target = getTextObj((TreeTableCell<?, ?>) cell); Point2D targetXY = target.localToParent(xoffset, yoffset); targetXY = node.localToScene(targetXY); super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset); }
Example #10
Source File: JavaFXListViewItemElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { Node cell = getPseudoComponent(); target = getTextObj((ListCell<?>) cell); Point2D targetXY = node.localToScene(xoffset, yoffset); super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset); }
Example #11
Source File: JavaFXTreeViewNodeElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { Node cell = getPseudoComponent(); target = getTextObj((TreeCell<?>) cell); Point2D targetXY = node.localToScene(xoffset, yoffset); super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset); }
Example #12
Source File: JavaFXTableCellElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { Node cell = getPseudoComponent(); target = getTextObj((TableCell<?, ?>) cell); Point2D targetXY = target.localToParent(xoffset, yoffset); targetXY = node.localToScene(targetXY); super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset); }
Example #13
Source File: JavaFXElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { verifyCanInteractWithElement(); EventQueueWait.requestFocus(node); IDevice mouse = driver.getDevices(); mouse.click(node, target, pickResult, Buttons.getButtonFor(button), clickCount, xoffset, yoffset); }
Example #14
Source File: FXEventQueueDevice.java From marathonv5 with Apache License 2.0 | 5 votes |
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)); } }
Example #15
Source File: FXEventQueueDevice.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void click(Node node, Node target, PickResult pickResult, Buttons button, int clickCount, double xoffset, double yoffset) { MouseButton b = button.getMouseButton(); dispatchMouseEvent(node, target, pickResult, button == Buttons.RIGHT, clickCount, b, xoffset, yoffset); deviceState.setNode(node); }
Example #16
Source File: JavaFXComboBoxOptionElement.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { Platform.runLater(() -> ((ComboBox<?>) getComponent()).getSelectionModel().select(option)); }
Example #17
Source File: JavaFXBrowserViewItem.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { parent.click(selector, frameId); }
Example #18
Source File: JavaFXWebViewItem.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { parent.click(selector); }
Example #19
Source File: JavaFXChoiceBoxOptionElement.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) { Platform.runLater(() -> ((ChoiceBox<?>) getComponent()).getSelectionModel().select(option)); }
Example #20
Source File: DockEvent.java From DockFX with GNU Lesser General Public License v3.0 | 2 votes |
/** * Returns information about the pick. * * @return new PickResult object that contains information about the pick */ public final PickResult getPickResult() { return pickResult; }
Example #21
Source File: DockEvent.java From DockFX with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs new DockEvent event.. * * @param eventType The type of the event. * @param x The x with respect to the source. Should be in scene coordinates if source == null or * source is not a Node. * @param y The y with respect to the source. Should be in scene coordinates if source == null or * source is not a Node. * @param screenX The x coordinate relative to screen. * @param screenY The y coordinate relative to screen. * @param pickResult pick result. Can be null, in this case a 2D pick result without any further * values is constructed based on the scene coordinates */ public DockEvent(EventType<? extends DockEvent> eventType, double x, double y, double screenX, double screenY, PickResult pickResult) { this(null, null, eventType, x, y, screenX, screenY, pickResult); }
Example #22
Source File: DockEvent.java From DockFX with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs new DockEvent event.. * * @param source the source of the event. Can be null. * @param target the target of the event. Can be null. * @param eventType The type of the event. * @param x The x with respect to the source. Should be in scene coordinates if source == null or * source is not a Node. * @param y The y with respect to the source. Should be in scene coordinates if source == null or * source is not a Node. * @param screenX The x coordinate relative to screen. * @param screenY The y coordinate relative to screen. * @param pickResult pick result. Can be null, in this case a 2D pick result without any further * values is constructed based on the scene coordinates */ public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType, double x, double y, double screenX, double screenY, PickResult pickResult) { this(source, target, eventType, x, y, screenX, screenY, pickResult, null); }
Example #23
Source File: IJavaFXElement.java From marathonv5 with Apache License 2.0 | votes |
public abstract void click(int button, Node target, PickResult pickResult, int clickCount, double x, double y);
Example #24
Source File: IDevice.java From marathonv5 with Apache License 2.0 | votes |
void click(Node component, Node target, PickResult pickResult, Buttons button, int clickCount, double xoffset, double yoffset);