Class MouseState

java.lang.Object
com.ardor3d.input.MouseState

public class MouseState extends Object
Describes the mouse state at some point in time.
  • Field Details

    • NOTHING

      public static final MouseState NOTHING
    • CLICK_TIME_MS

      public static long CLICK_TIME_MS
  • Constructor Details

    • MouseState

      public MouseState(int x, int y, int dx, int dy, int dwheel, EnumMap<MouseButton,ButtonState> buttonStates, EnumMap<MouseButton,Integer> clicks)
      Constructs a new MouseState instance.
      Parameters:
      x - the mouse's x position
      y - the mouse's y position
      dx - the delta in the mouse's x position since the last update
      dy - the delta in the mouse's y position since the last update
      dwheel - the delta in the mouse's wheel movement since the last update
      buttonStates - the states of the various given buttons.
      clicks - the number of times each button has been clicked
  • Method Details

    • getX

      public int getX()
    • getY

      public int getY()
    • getDx

      public int getDx()
    • getDy

      public int getDy()
    • getDwheel

      public int getDwheel()
    • hasButtonState

      public boolean hasButtonState(ButtonState state)
      Parameters:
      state - the button state to look for
      Returns:
      true if at least one mouse button is in the given button state.
    • hasButtonState

      public boolean hasButtonState(MouseButton button)
      Parameters:
      button - the button to look for
      Returns:
      true if the given mouse button is currently mapped to a state.
    • getButtonStates

      public EnumMap<MouseButton,ButtonState> getButtonStates()
      Returns all the buttons' states. It could be easier for most classes to use the getButtonState(MouseButton) methods, and that also results in less object creation.
      Returns:
      a defensive copy of the states of all the buttons at this point in time.
    • getButtonStates

      public EnumMap<MouseButton,ButtonState> getButtonStates(EnumMap<MouseButton,ButtonState> store)
      Returns all the buttons' states. It could be easier for most classes to use the getButtonState(MouseButton) methods, and that also results in less object creation.
      Parameters:
      store - a map to store the states in... any values in store are cleared first. If store is null, a new map is created.
      Returns:
      a defensive copy of the states of all the buttons at this point in time.
    • getButtonState

      public ButtonState getButtonState(MouseButton button)
      Returns the current state for the supplied button, or UP if no state for that button is registered.
      Parameters:
      button - the mouse button to check
      Returns:
      the button's state, or ButtonState.UP if no button state registered.
    • getButtonsReleasedSince

      public EnumSet<MouseButton> getButtonsReleasedSince(MouseState previous)
    • getButtonsPressedSince

      public EnumSet<MouseButton> getButtonsPressedSince(MouseState previous)
    • getClickCounts

      public EnumMap<MouseButton,Integer> getClickCounts()
      Returns all the buttons' states. It could be easier for most classes to use the getClickCount(MouseButton) method, and that also results in less object creation.
      Returns:
      a defensive copy of the click counts of all the buttons at this point in time.
    • getClickCounts

      public EnumMap<MouseButton,Integer> getClickCounts(EnumMap<MouseButton,Integer> store)
    • getClickCount

      public int getClickCount(MouseButton button)
      Returns the click count of a mouse button as of this frame. Click counts are non-zero only for frames when the mouse button is released. A double-click sequence, for instance, could show up like this:
      • Frame 1, mouse button pressed - click count == 0
      • Frame 2, mouse button down - click count == 0
      • Frame 3, mouse button released - click count == 1
      • Frame 4, mouse button up - click count == 0
      • Frame 5, mouse button pressed - click count == 0
      • Frame 6, mouse button down - click count == 0
      • Frame 7, mouse button released - click count == 2
      Whether or not a mouse press/release sequence counts as a click (or double-click) depends on the time passed between them. See CLICK_TIME_MS.
      Parameters:
      button - the button to check for clicks
      Returns:
      the click count in this frame
    • getButtonsClicked

      public EnumSet<MouseButton> getButtonsClicked()
      Returns a new EnumSet of all buttons that were clicked this frame.
      Returns:
      every mouse button whose click count this frame is > 0
    • toString

      public String toString()
      Overrides:
      toString in class Object