Package gui.event
Class MouseBinding
java.lang.Object
gui.event.MouseBinding
A simple class that represents a mouse button and any modifiers needed to bind an action to a
mouse input event.
The modifiers used by this class will include the button down mask for the given button. This
is done to match how MouseEvent
uses its modifiers.
-
Constructor Summary
ConstructorDescriptionMouseBinding
(int button) Construct a binding with the given button number of the desired mouse button (e.g., 1, 2,...)MouseBinding
(int button, int modifiers) Construct a binding with the given button number of the desired mouse button (e.g., 1, 2,...) as well as any desired modifiers (e.g.,InputEvent.SHIFT_DOWN_MASK
). -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
The button used by this classA user-friendly display string for this classint
The modifiers used by this classstatic MouseBinding
Create a mouse binding for the given eventstatic MouseBinding
getMouseBinding
(String mouseString) Creates a mouse binding from the given string.int
hashCode()
boolean
Returns true if the given mouse event is the mouse released event for the mouse button used by this class.toString()
-
Constructor Details
-
MouseBinding
public MouseBinding(int button) Construct a binding with the given button number of the desired mouse button (e.g., 1, 2,...)- Parameters:
button
- the button number
-
MouseBinding
public MouseBinding(int button, int modifiers) Construct a binding with the given button number of the desired mouse button (e.g., 1, 2,...) as well as any desired modifiers (e.g.,InputEvent.SHIFT_DOWN_MASK
).- Parameters:
button
- the button numbermodifiers
- the event modifiers
-
-
Method Details
-
getButton
public int getButton()The button used by this class- Returns:
- the button used by this class
-
getModifiers
public int getModifiers()The modifiers used by this class- Returns:
- the modifiers used by this class
-
getDisplayText
A user-friendly display string for this class- Returns:
- a user-friendly display string for this class
-
getMouseBinding
Create a mouse binding for the given event- Parameters:
e
- the event- Returns:
- the mouse binding
-
getMouseBinding
Creates a mouse binding from the given string. The string is expected to be of the form:Ctrl+Button1
, which is the form of the text generated bygetDisplayText()
.- Parameters:
mouseString
- the mouse string- Returns:
- the mouse binding or null if an invalid string was given
-
isMatchingRelease
Returns true if the given mouse event is the mouse released event for the mouse button used by this class. This method will ignore modifier text, since modifiers can be pressed and released independent of the mouse button's release.- Parameters:
e
- the event- Returns:
- true if the given mouse event is the mouse released event for the mouse button used by this class
-
toString
-
hashCode
public int hashCode() -
equals
-