Class MouseRobotImpl

java.lang.Object
org.testfx.robot.impl.MouseRobotImpl
All Implemented Interfaces:
MouseRobot

public class MouseRobotImpl extends Object implements MouseRobot
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final BaseRobot
     
    private final Set<javafx.scene.input.MouseButton>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final Set<javafx.scene.input.MouseButton>
    Gets the mouse buttons that have been pressed but not yet released.
    void
    move(javafx.geometry.Point2D location)
    Moves the mouse to the given location.
    void
    moveNoWait(javafx.geometry.Point2D location)
    Moves the mouse to the given location.
    void
    press(javafx.scene.input.MouseButton... buttons)
    Presses the given mouse buttons, until explicitly released via MouseRobot.release(MouseButton...).
    private void
    pressButton(javafx.scene.input.MouseButton button)
     
    void
    pressNoWait(javafx.scene.input.MouseButton... buttons)
    Presses the given mouse buttons, until explicitly released via MouseRobot.release(MouseButton...).
    void
    release(javafx.scene.input.MouseButton... buttons)
    Releases the given mouse buttons.
    private void
    releaseButton(javafx.scene.input.MouseButton button)
     
    void
    releaseNoWait(javafx.scene.input.MouseButton... buttons)
    Releases the given mouse buttons.
    void
    scroll(int wheelAmount)
    Scrolls the mouse wheel by the given amount.
    void
    scrollNoWait(int wheelAmount)
    Scrolls the mouse wheel by the given amount.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • baseRobot

      private final BaseRobot baseRobot
    • pressedButtons

      private final Set<javafx.scene.input.MouseButton> pressedButtons
  • Constructor Details

    • MouseRobotImpl

      public MouseRobotImpl(BaseRobot baseRobot)
  • Method Details

    • press

      public void press(javafx.scene.input.MouseButton... buttons)
      Description copied from interface: MouseRobot
      Presses the given mouse buttons, until explicitly released via MouseRobot.release(MouseButton...). Once pressed, calls WaitForAsyncUtils.waitForFxEvents().

      Note: passing in an empty MouseButton[] will call press(MouseButton.PRIMARY).

      Specified by:
      press in interface MouseRobot
      Parameters:
      buttons - the mouse buttons to press
    • pressNoWait

      public void pressNoWait(javafx.scene.input.MouseButton... buttons)
      Description copied from interface: MouseRobot
      Presses the given mouse buttons, until explicitly released via MouseRobot.release(MouseButton...). Once pressed, WaitForAsyncUtils.waitForFxEvents() is not called.

      Note: passing in an empty MouseButton[] will call press(MouseButton.PRIMARY).

      Specified by:
      pressNoWait in interface MouseRobot
      Parameters:
      buttons - the mouse buttons to press without waiting afterwards
    • release

      public void release(javafx.scene.input.MouseButton... buttons)
      Description copied from interface: MouseRobot
      Releases the given mouse buttons. Once pressed, calls WaitForAsyncUtils.waitForFxEvents().

      Note: passing in an empty MouseButton[] will release all pressed MouseButtons.

      Specified by:
      release in interface MouseRobot
      Parameters:
      buttons - the mouse buttons to release
    • releaseNoWait

      public void releaseNoWait(javafx.scene.input.MouseButton... buttons)
      Description copied from interface: MouseRobot
      Releases the given mouse buttons. Once pressed, WaitForAsyncUtils.waitForFxEvents() is not called.

      Note: passing in an empty MouseButton[] will release all pressed MouseButtons.

      Specified by:
      releaseNoWait in interface MouseRobot
      Parameters:
      buttons - the mouse buttons to release without waiting afterwards
    • move

      public void move(javafx.geometry.Point2D location)
      Description copied from interface: MouseRobot
      Moves the mouse to the given location. Once moved, calls WaitForAsyncUtils.waitForFxEvents().
      Specified by:
      move in interface MouseRobot
      Parameters:
      location - the location to move the mouse to
    • moveNoWait

      public void moveNoWait(javafx.geometry.Point2D location)
      Description copied from interface: MouseRobot
      Moves the mouse to the given location. Once moved, WaitForAsyncUtils.waitForFxEvents() is not called.
      Specified by:
      moveNoWait in interface MouseRobot
      Parameters:
      location - the location to move the mouse to without waiting afterwards
    • scroll

      public void scroll(int wheelAmount)
      Description copied from interface: MouseRobot
      Scrolls the mouse wheel by the given amount. Once scrolled, calls WaitForAsyncUtils.waitForFxEvents().
      Specified by:
      scroll in interface MouseRobot
      Parameters:
      wheelAmount - the amount to scroll the mouse by
    • scrollNoWait

      public void scrollNoWait(int wheelAmount)
      Description copied from interface: MouseRobot
      Scrolls the mouse wheel by the given amount. Once scrolled, WaitForAsyncUtils.waitForFxEvents() is not called.
      Specified by:
      scrollNoWait in interface MouseRobot
      Parameters:
      wheelAmount - the amount to scroll the mouse by without waiting afterwards
    • getPressedButtons

      public final Set<javafx.scene.input.MouseButton> getPressedButtons()
      Description copied from interface: MouseRobot
      Gets the mouse buttons that have been pressed but not yet released.
      Specified by:
      getPressedButtons in interface MouseRobot
      Returns:
      an (unmodifiable) set containing the pressed (but not yet released) buttons
    • pressButton

      private void pressButton(javafx.scene.input.MouseButton button)
    • releaseButton

      private void releaseButton(javafx.scene.input.MouseButton button)