Package greenfoot

Class MouseInfo

java.lang.Object
greenfoot.MouseInfo

public class MouseInfo extends Object
This class contains information about the current status of the mouse. You can get a MouseInfo object via Greenfoot.getMouseInfo().
See Also:
  • Method Details

    • getX

      public int getX()
      Return the current x position of the mouse cursor.
      Returns:
      the x position in grid coordinates
    • getY

      public int getY()
      Return the current y position of the mouse cursor.
      Returns:
      the y position in grid coordinates
    • getActor

      public Actor getActor()
      Return the actor (if any) that the current mouse behaviour is related to. If the mouse was clicked or pressed the actor it was clicked on will be returned. If the mouse was dragged or a drag ended, the actor where the drag started will be returned. If the mouse was moved, it will return the actor that the mouse is currently over.
      Returns:
      Actor that the current mouse behaviour relates to, or null if there is no actor related to current behaviour.
    • getButton

      public int getButton()
      The number of the pressed or clicked button (if any).
      Returns:
      The button number. Usually 1 is the left button, 2 is the middle button and 3 is the right button.
    • getClickCount

      public int getClickCount()
      Return the number of mouse clicks associated with this mouse event.
      Returns:
      The number of times a button has been clicked.
    • toString

      public String toString()
      Overrides:
      toString in class Object