Class 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 every NativeMouseWheelListener object which is registered to receive mouse wheel events using the GlobalScreen.addNativeMouseWheelListener(NativeMouseWheelListener) method. The GlobalScreen object then dispatches a NativeMouseWheelEvent 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 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 new NativeMouseWheelEvent 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 _MASK InputEvent 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 are WHEEL_UNIT_SCROLL and WHEEL_BLOCK_SCROLL.
        scrollAmount - for scrollType WHEEL_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 new NativeMouseWheelEvent 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 _MASK InputEvent 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 are WHEEL_UNIT_SCROLL and WHEEL_BLOCK_SCROLL.
        scrollAmount - for scrollType WHEEL_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 are WHEEL_VERTICAL_DIRECTION and WHEEL_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 if getScrollType returns NativeMouseWheelEvent.WHEEL_UNIT_SCROLL
        Returns:
        number of units to scroll, or an undefined value if getScrollType returns NativeMouseWheelEvent.WHEEL_BLOCK_SCROLL
        See Also:
        getScrollType()
      • 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 class NativeMouseEvent
        Returns:
        a string identifying the native event and its attributes.