Class NativeMouseWheelEvent
- java.lang.Object
-
- java.util.EventObject
-
- com.github.kwhat.jnativehook.NativeInputEvent
-
- com.github.kwhat.jnativehook.mouse.NativeMouseEvent
-
- com.github.kwhat.jnativehook.mouse.NativeMouseWheelEvent
-
- All Implemented Interfaces:
Serializable
public class NativeMouseWheelEvent extends NativeMouseEvent
An event which indicates that the mouse wheel was rotated on the system. This event is not limited to a particular component's scope or visibility.A
NativeMouseWheelEvent
object is passed to everyNativeMouseWheelListener
object which is registered to receive mouse wheel events using theGlobalScreen.addNativeMouseWheelListener(NativeMouseWheelListener)
method. TheGlobalScreen
object then dispatches aNativeMouseWheelEvent
to each listener.Platforms offer customization of the amount of scrolling that should take place when the mouse wheel is moved. The two most common settings are to scroll a certain number of "units" (commonly lines of text in a text-based component) or an entire "block" (similar to page-up/page-down). The
NativeMouseWheelEvent
offers methods for conforming to the underlying platform settings. These platform settings can be changed at any time by the user.NativeMouseWheelEvents
reflect the most recent settings.- Since:
- 1.1
- Version:
- 2.0
- Author:
- Alexander Barker (alex@1stleg.com)
- See Also:
GlobalScreen
,NativeMouseWheelListener
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
WHEEL_BLOCK_SCROLL
Constant representing scrolling by a "block" (like scrolling with page-up, page-down keys).static int
WHEEL_HORIZONTAL_DIRECTION
Constant representing scrolling in the horizontal direction.static int
WHEEL_UNIT_SCROLL
Constant representing scrolling by "units" (like scrolling with the arrow keys).static int
WHEEL_VERTICAL_DIRECTION
Constant representing scrolling in the vertical direction.-
Fields inherited from class com.github.kwhat.jnativehook.mouse.NativeMouseEvent
BUTTON1, BUTTON2, BUTTON3, BUTTON4, BUTTON5, NATIVE_MOUSE_CLICKED, NATIVE_MOUSE_DRAGGED, NATIVE_MOUSE_FIRST, NATIVE_MOUSE_LAST, NATIVE_MOUSE_MOVED, NATIVE_MOUSE_PRESSED, NATIVE_MOUSE_RELEASED, NATIVE_MOUSE_WHEEL, NOBUTTON
-
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_MASK
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description NativeMouseWheelEvent(int id, int modifiers, int x, int y, int clickCount, int scrollType, int scrollAmount, int wheelRotation)
Instantiates a newNativeMouseWheelEvent
object with a vertical direction.NativeMouseWheelEvent(int id, int modifiers, int x, int y, int clickCount, int scrollType, int scrollAmount, int wheelRotation, int wheelDirection)
Instantiates a newNativeMouseWheelEvent
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getScrollAmount()
Returns the number of units that should be scrolled per click of mouse wheel rotation.int
getScrollType()
Returns the type of scrolling that should take place in response to this event.int
getWheelDirection()
Returns the direction of scrolling that should take place in response to this event.int
getWheelRotation()
Returns the number of "clicks" the mouse wheel was rotated.String
paramString()
Returns a parameter string identifying the native event.-
Methods inherited from class com.github.kwhat.jnativehook.mouse.NativeMouseEvent
getButton, getClickCount, getPoint, getX, getY
-
Methods inherited from class com.github.kwhat.jnativehook.NativeInputEvent
getID, getModifiers, getModifiersText, getWhen, setModifiers
-
Methods inherited from class java.util.EventObject
getSource, toString
-
-
-
-
Field Detail
-
WHEEL_UNIT_SCROLL
public static final int WHEEL_UNIT_SCROLL
Constant representing scrolling by "units" (like scrolling with the arrow keys).- See Also:
- Constant Field Values
-
WHEEL_BLOCK_SCROLL
public static final int WHEEL_BLOCK_SCROLL
Constant representing scrolling by a "block" (like scrolling with page-up, page-down keys).- See Also:
- Constant Field Values
-
WHEEL_VERTICAL_DIRECTION
public static final int WHEEL_VERTICAL_DIRECTION
Constant representing scrolling in the vertical direction.- Since:
- 2.1
- See Also:
- Constant Field Values
-
WHEEL_HORIZONTAL_DIRECTION
public static final int WHEEL_HORIZONTAL_DIRECTION
Constant representing scrolling in the horizontal direction.- Since:
- 2.1
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NativeMouseWheelEvent
public NativeMouseWheelEvent(int id, int modifiers, int x, int y, int clickCount, int scrollType, int scrollAmount, int wheelRotation)
Instantiates a newNativeMouseWheelEvent
object with a vertical direction.- 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 _MASKInputEvent
modifiers.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.scrollType
- the type of scrolling which should take place in response to this event; valid values areWHEEL_UNIT_SCROLL
andWHEEL_BLOCK_SCROLL
.scrollAmount
- for scrollTypeWHEEL_UNIT_SCROLL
, the number of units to be scrolled.wheelRotation
- the amount that the mouse wheel was rotated (the number of "clicks")- See Also:
NativeMouseWheelEvent(int, int, int, int, int, int, int, int, int)
,NativeMouseEvent(int, int, int, int, int)
-
NativeMouseWheelEvent
public NativeMouseWheelEvent(int id, int modifiers, int x, int y, int clickCount, int scrollType, int scrollAmount, int wheelRotation, int wheelDirection)
Instantiates a newNativeMouseWheelEvent
object.- 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 _MASKInputEvent
modifiers.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.scrollType
- the type of scrolling which should take place in response to this event; valid values areWHEEL_UNIT_SCROLL
andWHEEL_BLOCK_SCROLL
.scrollAmount
- for scrollTypeWHEEL_UNIT_SCROLL
, the number of units to be scrolled.wheelRotation
- the amount that the mouse wheel was rotated (the number of "clicks")wheelDirection
- the direction of scrolling which should take place in response to this event; valid values areWHEEL_VERTICAL_DIRECTION
andWHEEL_HORIZONTAL_DIRECTION
.- Since:
- 2.1
- See Also:
NativeMouseEvent(int, int, int, int, int)
-
-
Method Detail
-
getScrollAmount
public int getScrollAmount()
Returns the number of units that should be scrolled per click of mouse wheel rotation. Only valid ifgetScrollType
returnsNativeMouseWheelEvent.WHEEL_UNIT_SCROLL
- Returns:
- number of units to scroll, or an undefined value if
getScrollType
returnsNativeMouseWheelEvent.WHEEL_BLOCK_SCROLL
- See Also:
getScrollType()
-
getScrollType
public int getScrollType()
Returns the type of scrolling that should take place in response to this event. This is determined by the native platform. Legal values are:- MouseWheelEvent.WHEEL_UNIT_SCROLL
- MouseWheelEvent.WHEEL_BLOCK_SCROLL
- Returns:
- either NativeMouseWheelEvent.WHEEL_UNIT_SCROLL or NativeMouseWheelEvent.WHEEL_BLOCK_SCROLL, , depending on the configuration of the native platform.
- See Also:
Adjustable.getUnitIncrement()
,Adjustable.getBlockIncrement()
,Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)
,Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)
-
getWheelRotation
public int getWheelRotation()
Returns the number of "clicks" the mouse wheel was rotated.- Returns:
- negative values if the mouse wheel was rotated up/away from the user, and positive values if the mouse wheel was rotated down/ toward(s) the user.
-
getWheelDirection
public int getWheelDirection()
Returns the direction of scrolling that should take place in response to this event. Legal values are:- MouseWheelEvent.WHEEL_VERTICAL_DIRECTION
- MouseWheelEvent.WHEEL_HORIZONTAL_DIRECTION
- Returns:
- either NativeMouseWheelEvent.WHEEL_VERTICAL_DIRECTION or NativeMouseWheelEvent.WHEEL_HORIZONTAL_DIRECTION. .
- Since:
- 2.1
-
paramString
public String paramString()
Returns a parameter string identifying the native event. This method is useful for event-logging and debugging.- Overrides:
paramString
in classNativeMouseEvent
- Returns:
- a string identifying the native event and its attributes.
-
-