Class NativeMouseEvent
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
NativeMouseWheelEvent
This low-level event is generated natively for:
-
Native Mouse Events
- a mouse button is pressed
- a mouse button is released
- the mouse wheel was moved
-
Native Mouse Motion Events
- the mouse is moved
- the mouse is dragged
A NativeMouseEvent object is passed to every
NativeMouseListener object which is registered to receive mouse
events using the GlobalScreen.addNativeMouseListener(com.github.kwhat.jnativehook.mouse.NativeMouseListener) method. The
GlobalScreen object then dispatches a
NativeMouseEvent to each listener.
A NativeMouseEvent object is also passed to every
NativeMouseMotionListener object which has been registered to
receive mouse motion events using the
GlobalScreen.addNativeMouseListener(com.github.kwhat.jnativehook.mouse.NativeMouseListener) method. The
GlobalScreen object then dispatches a
NativeMouseEvent to each listener.
When a mouse button is clicked, events are generated and sent to the
registered NativeMouseListeners. The state of modifiers can be
retrieved using NativeInputEvent.getModifiers(). All modifiers returned
by NativeInputEvent.getModifiers() reflect the current state of all
modifiers and buttons.
- Since:
- 1.0
- Version:
- 2.0
- Author:
- Alexander Barker (alex@1stleg.com)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates mouse button #1; used by getButton().static final intIndicates mouse button #2; used by getButton().static final intIndicates mouse button #3; used by getButton().static final intIndicates mouse button #4; used by getButton().static final intIndicates mouse button #5; used by getButton().static final intThe native mouse pressed event.static final intThe native mouse dragged event.static final intThe first number in the range of id's used for native mouse events.static final intThe last number in the range of id's used for native mouse events.static final intThe native mouse moved event.static final intThe native mouse pressed event.static final intThe native mouse released event.static final intThe native mouse dragged event.static final intIndicates no mouse buttons; used by getButton().Fields inherited from class com.github.kwhat.jnativehook.NativeInputEvent
ALT_L_MASK, ALT_MASK, ALT_R_MASK, BUTTON1_MASK, BUTTON2_MASK, BUTTON3_MASK, BUTTON4_MASK, BUTTON5_MASK, CAPS_LOCK_MASK, CTRL_L_MASK, CTRL_MASK, CTRL_R_MASK, META_L_MASK, META_MASK, META_R_MASK, NUM_LOCK_MASK, SCROLL_LOCK_MASK, SHIFT_L_MASK, SHIFT_MASK, SHIFT_R_MASKFields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionNativeMouseEvent(int id, int modifiers, int x, int y, int clickCount) Instantiates a newNativeMouseEventobject.NativeMouseEvent(int id, int modifiers, int x, int y, int clickCount, int button) Instantiates a newNativeMouseEventobject. -
Method Summary
Modifier and TypeMethodDescriptionintReturns which, if any, of the mouse buttons has changed state.intReturns the number of button clicks associated with this event.getPoint()Returns the x,y position of the native event.intgetX()Returns the x coordinate of the native event.intgetY()Returns the y coordinate of the native event.Returns a parameter string identifying the native event.Methods inherited from class com.github.kwhat.jnativehook.NativeInputEvent
getID, getModifiers, getModifiersText, getWhen, setModifiersMethods inherited from class java.util.EventObject
getSource, toString
-
Field Details
-
NATIVE_MOUSE_FIRST
public static final int NATIVE_MOUSE_FIRSTThe first number in the range of id's used for native mouse events.- See Also:
-
NATIVE_MOUSE_LAST
public static final int NATIVE_MOUSE_LASTThe last number in the range of id's used for native mouse events.- See Also:
-
NATIVE_MOUSE_CLICKED
public static final int NATIVE_MOUSE_CLICKEDThe native mouse pressed event. ThisNativeMouseEventoccurs when a mouse button is pressed and released.- See Also:
-
NATIVE_MOUSE_PRESSED
public static final int NATIVE_MOUSE_PRESSEDThe native mouse pressed event. ThisNativeMouseEventoccurs when a mouse button is depressed.- See Also:
-
NATIVE_MOUSE_RELEASED
public static final int NATIVE_MOUSE_RELEASEDThe native mouse released event. ThisNativeMouseEventoccurs when a mouse button is released.- See Also:
-
NATIVE_MOUSE_MOVED
public static final int NATIVE_MOUSE_MOVEDThe native mouse moved event. ThisNativeMouseEventoccurs when the mouse pointer changes position.- See Also:
-
NATIVE_MOUSE_DRAGGED
public static final int NATIVE_MOUSE_DRAGGEDThe native mouse dragged event. ThisNativeMouseEventoccurs when the mouse pointer changes position while a mouse button is pressed.- See Also:
-
NATIVE_MOUSE_WHEEL
public static final int NATIVE_MOUSE_WHEELThe native mouse dragged event. ThisNativeMouseEventoccurs when the mouse wheel is rotated.- See Also:
-
NOBUTTON
public static final int NOBUTTONIndicates no mouse buttons; used by getButton().- See Also:
-
BUTTON1
public static final int BUTTON1Indicates mouse button #1; used by getButton().- See Also:
-
BUTTON2
public static final int BUTTON2Indicates mouse button #2; used by getButton().- See Also:
-
BUTTON3
public static final int BUTTON3Indicates mouse button #3; used by getButton().- See Also:
-
BUTTON4
public static final int BUTTON4Indicates mouse button #4; used by getButton().- See Also:
-
BUTTON5
public static final int BUTTON5Indicates mouse button #5; used by getButton().- See Also:
-
-
Constructor Details
-
NativeMouseEvent
public NativeMouseEvent(int id, int modifiers, int x, int y, int clickCount) Instantiates a newNativeMouseEventobject.- Parameters:
id- an integer that identifies the native event type.modifiers- a modifier mask describing the modifier keys and mouse buttons active for the event.NativeInputEvent _MASKmodifiers should be used as they are not compatible with the extended _DOWN_MASK or the old _MASKInputEventmodifiers.x- the x coordinate of the native pointer.y- the y coordinate of the native pointer.clickCount- the number of button clicks associated with this event.- Since:
- 1.1
-
NativeMouseEvent
public NativeMouseEvent(int id, int modifiers, int x, int y, int clickCount, int button) Instantiates a newNativeMouseEventobject.- Parameters:
id- an integer that identifies the native event type.modifiers- a modifier mask describing the modifier keys and mouse buttons active for the event.NativeInputEvent_MASK modifiers should be used as they are not compatible with the extended _DOWN_MASK or the old _MASKInputEventmodifiers.x- the x coordinate of the native pointer.y- the y coordinate of the native pointer.clickCount- the number of button clicks associated with this event.button- The mouse buttons that have changed state. NOBUTTON, BUTTON1, BUTTON2, BUTTON3, BUTTON5 or BUTTON5.- Since:
- 1.1
-
-
Method Details
-
getButton
public int getButton()Returns which, if any, of the mouse buttons has changed state.- Returns:
- one of the following constants:
NOBUTTON,BUTTON1,BUTTON2,BUTTON3,BUTTON4orBUTTON5
-
getClickCount
public int getClickCount()Returns the number of button clicks associated with this event.- Returns:
- An integer indicating the number of button clicks
- Since:
- 1.1
-
getPoint
Returns the x,y position of the native event.- Returns:
- a
Pointobject containing the x and y coordinates of the native pointer - Since:
- 1.1
-
getX
public int getX()Returns the x coordinate of the native event.- Returns:
- x an integer indicating horizontal position of the native pointer
-
getY
public int getY()Returns the y coordinate of the native event.- Returns:
- y an integer indicating horizontal position of the native pointer
-
paramString
Returns a parameter string identifying the native event. This method is useful for event-logging and debugging.- Overrides:
paramStringin classNativeInputEvent- Returns:
- a string identifying the native event and its attributes.
-