Package greenfoot
Class MouseInfo
- java.lang.Object
-
- greenfoot.MouseInfo
-
public class MouseInfo extends java.lang.Object
This class contains information about the current status of the mouse. You can get a MouseInfo object viaGreenfoot.getMouseInfo()
.- Version:
- 2.4
- Author:
- Poul Henriksen
- See Also:
Greenfoot.getMouseInfo()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Actor
getActor()
Return the actor (if any) that the current mouse behaviour is related to.int
getButton()
The number of the pressed or clicked button (if any).int
getClickCount()
Return the number of mouse clicks associated with this mouse event.int
getX()
Return the current x position of the mouse cursor.int
getY()
Return the current y position of the mouse cursor.java.lang.String
toString()
-
-
-
Method Detail
-
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 java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-