JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.newt.event.MouseEvent Class Reference

Pointer event of type PointerType. More...

Inheritance diagram for com.jogamp.newt.event.MouseEvent:
Collaboration diagram for com.jogamp.newt.event.MouseEvent:

Classes

enum  PointerClass
 Class of pointer types. More...
 
enum  PointerType
 Type of pointer devices. More...
 

Public Member Functions

 MouseEvent (final short eventType, final Object source, final long when, final int modifiers, final int x, final int y, final short clickCount, final short button, final float[] rotationXYZ, final float rotationScale)
 Constructor for traditional one-pointer event. More...
 
 MouseEvent (final short eventType, final Object source, final long when, final int modifiers, final PointerType pointerType[], final short[] pointerID, final int[] x, final int[] y, final float[] pressure, final float maxPressure, final short button, final short clickCount, final float[] rotationXYZ, final float rotationScale)
 Constructor for a multiple-pointer event. More...
 
final MouseEvent createVariant (final short newEventType)
 
final int getPointerCount ()
 See details for multiple-pointer events. More...
 
final PointerType getPointerType (final int index)
 See details for multiple-pointer events. More...
 
final PointerType[] getAllPointerTypes ()
 See details for multiple-pointer events. More...
 
final short getPointerId (final int index)
 Return the pointer id for the given index or -1 if index not available. More...
 
final int getPointerIdx (final short id)
 See details for multiple-pointer events. More...
 
final short[] getAllPointerIDs ()
 See details for multiple-pointer events. More...
 
final short getButton ()
 Returns the button number, e.g. More...
 
final short getClickCount ()
 
final int getX ()
 See details for multiple-pointer events. More...
 
final int getY ()
 See details for multiple-pointer events. More...
 
final int getX (final int index)
 See details for multiple-pointer events. More...
 
final int getY (final int index)
 See details for multiple-pointer events. More...
 
final int[] getAllX ()
 See details for multiple-pointer events. More...
 
final int[] getAllY ()
 See details for multiple-pointer events. More...
 
final float getPressure (final boolean normalized)
 
final float getPressure (final int index, final boolean normalized)
 See details for multiple-pointer events. More...
 
final float[] getAllPressures ()
 See details for multiple-pointer events. More...
 
final float getMaxPressure ()
 Returns the maximum pressure known for the input device generating this event. More...
 
final float[] getRotation ()
 Returns a 3-component float array filled with the values of the rotational axis in the following order: horizontal-, vertical- and z-axis. More...
 
final float getRotationScale ()
 Returns the scale used to determine the rotation value, which semantics depends on the pointer type's PointerClass. More...
 
final String toString ()
 
final StringBuilder toString (StringBuilder sb)
 
- Public Member Functions inherited from com.jogamp.newt.event.InputEvent
final int getModifiers ()
 Return the modifier bits of this event, e.g. More...
 
final boolean isAltDown ()
 getModifiers() contains ALT_MASK. More...
 
final boolean isAltGraphDown ()
 getModifiers() contains ALT_GRAPH_MASK. More...
 
final boolean isControlDown ()
 getModifiers() contains CTRL_MASK. More...
 
final boolean isMetaDown ()
 getModifiers() contains META_MASK. More...
 
final boolean isShiftDown ()
 getModifiers() contains SHIFT_MASK. More...
 
final boolean isAutoRepeat ()
 getModifiers() contains AUTOREPEAT_MASK. More...
 
final boolean isConfined ()
 getModifiers() contains CONFINED_MASK. More...
 
final boolean isInvisible ()
 getModifiers() contains INVISIBLE_MASK. More...
 
final StringBuilder getModifiersString (StringBuilder sb)
 
final short[] getButtonsDown ()
 See also MouseEvent's section about Multiple-Pointer Events. More...
 
final boolean isButtonDown (final int button)
 See also MouseEvent's section about Multiple-Pointer Events. More...
 
final int getButtonDownCount ()
 Returns the number of pressed buttons by counting the set bits: More...
 
final boolean isAnyButtonDown ()
 Returns true if at least one button is pressed, otherwise false: More...
 
String toString ()
 
StringBuilder toString (StringBuilder sb)
 
- Public Member Functions inherited from com.jogamp.newt.event.NEWTEvent
final short getEventType ()
 Returns the event type of this event. More...
 
final long getWhen ()
 Returns the timestamp, in milliseconds, of this event. More...
 
final void setAttachment (final Object attachment)
 Attach the passed object to this event. More...
 
final Object getAttachment ()
 
final boolean isConsumed ()
 Returns true if this events has been consumed, otherwise false. More...
 
final void setConsumed (final boolean consumed)
 If consumed is true, this event is marked as consumed, ie. More...
 
String toString ()
 
StringBuilder toString (StringBuilder sb)
 

Static Public Member Functions

static final float[] getRotationXYZ (final float rotationXorY, final int mods)
 Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). More...
 
static final short getClickTimeout ()
 
static String getEventTypeString (final short type)
 
- Static Public Member Functions inherited from com.jogamp.newt.event.InputEvent
static final int getButtonMask (final int button)
 Returns the corresponding button mask for the given button. More...
 
- Static Public Member Functions inherited from com.jogamp.newt.event.NEWTEvent
static String toHexString (final short hex)
 

Static Public Attributes

static final short BUTTON1 = 1
 ID for button 1, value 1 More...
 
static final short BUTTON2 = 2
 ID for button 2, value 2 More...
 
static final short BUTTON3 = 3
 ID for button 3, value 3 More...
 
static final short BUTTON4 = 4
 ID for button 4, value 4 More...
 
static final short BUTTON5 = 5
 ID for button 5, value 5 More...
 
static final short BUTTON6 = 6
 ID for button 6, value 6 More...
 
static final short BUTTON7 = 7
 ID for button 6, value 7 More...
 
static final short BUTTON8 = 8
 ID for button 6, value 8 More...
 
static final short BUTTON9 = 9
 ID for button 6, value 9 More...
 
static final short BUTTON_COUNT = 16
 Maximum number of buttons, value 16 More...
 
static final short EVENT_MOUSE_CLICKED = 200
 
static final short EVENT_MOUSE_ENTERED = 201
 Only generated for PointerType#Mouse. More...
 
static final short EVENT_MOUSE_EXITED = 202
 Only generated for PointerType#Mouse. More...
 
static final short EVENT_MOUSE_PRESSED = 203
 
static final short EVENT_MOUSE_RELEASED = 204
 
static final short EVENT_MOUSE_MOVED = 205
 
static final short EVENT_MOUSE_DRAGGED = 206
 
static final short EVENT_MOUSE_WHEEL_MOVED = 207
 
- Static Public Attributes inherited from com.jogamp.newt.event.InputEvent
static final int SHIFT_MASK = 1 << 0
 
static final int CTRL_MASK = 1 << 1
 
static final int META_MASK = 1 << 2
 
static final int ALT_MASK = 1 << 3
 
static final int ALT_GRAPH_MASK = 1 << 4
 
static final int BUTTON1_MASK = 1 << 5
 
static final int BUTTON2_MASK = 1 << 6
 
static final int BUTTON3_MASK = 1 << 7
 
static final int BUTTON4_MASK = 1 << 8
 
static final int BUTTON5_MASK = 1 << 9
 
static final int BUTTON6_MASK = 1 << 10
 
static final int BUTTON7_MASK = 1 << 11
 
static final int BUTTON8_MASK = 1 << 12
 
static final int BUTTON9_MASK = 1 << 13
 
static final int BUTTONLAST_MASK = 1 << 20
 
static final int BUTTONALL_MASK = 0xffff << 5
 
static final int AUTOREPEAT_MASK = 1 << 29
 Event is caused by auto-repeat. More...
 
static final int CONFINED_MASK = 1 << 30
 Pointer is confined, see Window#confinePointer(boolean). More...
 
static final int INVISIBLE_MASK = 1 << 31
 Pointer is invisible, see Window#setPointerVisible(boolean). More...
 
- Static Public Attributes inherited from com.jogamp.newt.event.NEWTEvent
static final Object consumedTag = new Object()
 See setConsumed(boolean) for description. More...
 

Additional Inherited Members

- Protected Member Functions inherited from com.jogamp.newt.event.InputEvent
 InputEvent (final short eventType, final Object source, final long when, final int modifiers)
 
- Protected Member Functions inherited from com.jogamp.newt.event.NEWTEvent
 NEWTEvent (final short eventType, final Object source, final long when)
 

Detailed Description

Pointer event of type PointerType.

The historical misleading class name may change in the future to PointerEvent.

http://www.w3.org/Submission/pointer-events/#pointerevent-interface

Unit of Coordinates

All pointer coordinates of this interface are represented in pixel units, see NativeSurface and NativeWindow.

Multiple-Pointer Events

In case an instance represents a multiple-pointer event, i.e. getPointerCount() is > 1, the first data element of the multiple-pointer fields represents the pointer triggering this event.
For example e.getX(0) at EVENT_MOUSE_PRESSED returns the data of the pressed pointer, etc.

Multiple-pointer event's button number is mapped to the first pointer ID triggering the event and the button mask bits in the modifiers field represent the pressed pointer IDs.

Users can query the pressed button and pointer count via InputEvent#getButtonDownCount() or use the simple query InputEvent#isAnyButtonDown().

If representing a single-pointer PointerType#Mouse event, pointer-ID is 0 and a button value of 0 denotes no button activity, i.e. PointerType#Mouse move.

Definition at line 73 of file MouseEvent.java.

Constructor & Destructor Documentation

◆ MouseEvent() [1/2]

com.jogamp.newt.event.MouseEvent.MouseEvent ( final short  eventType,
final Object  source,
final long  when,
final int  modifiers,
final int  x,
final int  y,
final short  clickCount,
final short  button,
final float[]  rotationXYZ,
final float  rotationScale 
)

Constructor for traditional one-pointer event.

Parameters
eventType
source
when
modifiers
xX-axis
yY-axis
clickCountMouse-button click-count
buttonbutton number, e.g. [BUTTON1..BUTTON_COUNT-1]. A button value of 0 denotes no button activity, i.e. PointerType#Mouse move.
rotationXYZRotation of all axis
rotationScaleRotation scale

Definition at line 187 of file MouseEvent.java.

◆ MouseEvent() [2/2]

com.jogamp.newt.event.MouseEvent.MouseEvent ( final short  eventType,
final Object  source,
final long  when,
final int  modifiers,
final PointerType  pointerType[],
final short[]  pointerID,
final int[]  x,
final int[]  y,
final float[]  pressure,
final float  maxPressure,
final short  button,
final short  clickCount,
final float[]  rotationXYZ,
final float  rotationScale 
)

Constructor for a multiple-pointer event.

First element of multiple-pointer arrays represents the pointer which triggered the event!

See details for multiple-pointer events.

Parameters
eventType
source
when
modifiers
pointerTypePointerType for each pointer (multiple pointer)
pointerIDPointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. A pointer-ID of -1 may also denote no pointer/button activity, i.e. PointerType#Mouse move.
xX-axis for each pointer (multiple pointer)
yY-axis for each pointer (multiple pointer)
pressurePressure for each pointer (multiple pointer)
maxPressureMaximum pointer pressure for all pointer
buttonCorresponding mouse-button
clickCountMouse-button click-count
rotationXYZRotation of all axis
rotationScaleRotation scale

Definition at line 237 of file MouseEvent.java.

Member Function Documentation

◆ createVariant()

final MouseEvent com.jogamp.newt.event.MouseEvent.createVariant ( final short  newEventType)

Definition at line 265 of file MouseEvent.java.

◆ getAllPointerIDs()

final short[] com.jogamp.newt.event.MouseEvent.getAllPointerIDs ( )

See details for multiple-pointer events.

Returns
array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers.

Definition at line 332 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getAllPointerTypes()

final PointerType[] com.jogamp.newt.event.MouseEvent.getAllPointerTypes ( )

See details for multiple-pointer events.

Returns
array of all PointerTypes for all pointers

Definition at line 293 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getAllPressures()

final float[] com.jogamp.newt.event.MouseEvent.getAllPressures ( )

See details for multiple-pointer events.

Returns
array of all raw, un-normalized pressures for all pointers

Definition at line 431 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getAllX()

final int[] com.jogamp.newt.event.MouseEvent.getAllX ( )

See details for multiple-pointer events.

Returns
array of all X-Coords for all pointers in pixel units.

Definition at line 393 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getAllY()

final int[] com.jogamp.newt.event.MouseEvent.getAllY ( )

See details for multiple-pointer events.

Returns
array of all Y-Coords for all pointers in pixel units.

Definition at line 401 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getButton()

final short com.jogamp.newt.event.MouseEvent.getButton ( )

Returns the button number, e.g.

[BUTTON1..BUTTON_COUNT-1].

A button value of 0 denotes no button activity, i.e. PointerType#Mouse move.

See details for multiple-pointer events.

Definition at line 345 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getClickCount()

final short com.jogamp.newt.event.MouseEvent.getClickCount ( )

Definition at line 349 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getClickTimeout()

static final short com.jogamp.newt.event.MouseEvent.getClickTimeout ( )
static

Definition at line 168 of file MouseEvent.java.

◆ getEventTypeString()

static String com.jogamp.newt.event.MouseEvent.getEventTypeString ( final short  type)
static

Definition at line 543 of file MouseEvent.java.

◆ getMaxPressure()

final float com.jogamp.newt.event.MouseEvent.getMaxPressure ( )

Returns the maximum pressure known for the input device generating this event.

This value may be self calibrating on devices/OS, where no known maximum pressure is known. Hence subsequent events may return a higher value.

Self calibrating maximum pressure is performed on:

  • Android

Definition at line 448 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getPointerCount()

final int com.jogamp.newt.event.MouseEvent.getPointerCount ( )

See details for multiple-pointer events.

Returns
the count of pointers involved in this event

Definition at line 274 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getPointerId()

final short com.jogamp.newt.event.MouseEvent.getPointerId ( final int  index)

Return the pointer id for the given index or -1 if index not available.

IDs start w/ 0 and are consecutive numbers.

See details for multiple-pointer events.

Definition at line 306 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getPointerIdx()

final int com.jogamp.newt.event.MouseEvent.getPointerIdx ( final short  id)

See details for multiple-pointer events.

Returns
the pointer index for the given pointer id or -1 if id not available.

Definition at line 317 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getPointerType()

final PointerType com.jogamp.newt.event.MouseEvent.getPointerType ( final int  index)

See details for multiple-pointer events.

Returns
the PointerType for the data at index or null if index not available.

Definition at line 282 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getPressure() [1/2]

final float com.jogamp.newt.event.MouseEvent.getPressure ( final boolean  normalized)
Parameters
normalizedif true, method returns the normalized pressure, i.e. pressure / maxPressure
Returns
The pressure associated with the pointer-index 0. The value of zero is return if not available.
See also
getMaxPressure()

Definition at line 411 of file MouseEvent.java.

◆ getPressure() [2/2]

final float com.jogamp.newt.event.MouseEvent.getPressure ( final int  index,
final boolean  normalized 
)

See details for multiple-pointer events.

Parameters
indexpointer-index within [0 .. getPointerCount()-1]
normalizedif true, method returns the normalized pressure, i.e. pressure / maxPressure
Returns
The pressure associated with the pointer-index. The value of zero is return if not available.
See also
getMaxPressure()

Definition at line 423 of file MouseEvent.java.

◆ getRotation()

final float[] com.jogamp.newt.event.MouseEvent.getRotation ( )

Returns a 3-component float array filled with the values of the rotational axis in the following order: horizontal-, vertical- and z-axis.

A vertical rotation of > 0.0f is up and < 0.0f is down.

A horizontal rotation of > 0.0f is left and < 0.0f is right.

A z-axis rotation of > 0.0f is back and < 0.0f is front.

However, on some OS this might be flipped due to the OS default behavior. The latter is true for OS X 10.7 (Lion) for example.

On PointerClass onscreen devices, i.e. touch screens, rotation events are usually produced by a 2-finger movement, where horizontal and vertical rotation values are filled.

On PointerClass offscreen devices, i.e. mouse, either the horizontal or the vertical rotation value is filled.

The InputEvent#SHIFT_MASK modifier is set in case |horizontal| > |vertical| value.
This can be utilized to implement only one 2d rotation direction, you may use isShiftDown() to query it.

In case the pointer type is mouse, events are usually send in steps of one, ie. -1.0f and 1.0f. Higher values may result due to fast scrolling. Fractional values may result due to slow scrolling with high resolution devices.
Here the button number refers to the wheel number.

In case the pointer type is of class PointerClass#Onscreen, e.g. touch screen, see getRotationScale() for semantics.

Definition at line 492 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getRotationScale()

final float com.jogamp.newt.event.MouseEvent.getRotationScale ( )

Returns the scale used to determine the rotation value, which semantics depends on the pointer type's PointerClass.

For PointerClass#Offscreen, the scale is usually 1.0f and denominates an abstract value without association to a physical value.

For PointerClass#Onscreen, the scale varies and denominates the divisor of the distance the finger[s] have moved on the screen. Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved.

Definition at line 509 of file MouseEvent.java.

◆ getRotationXYZ()

static final float[] com.jogamp.newt.event.MouseEvent.getRotationXYZ ( final float  rotationXorY,
final int  mods 
)
static

Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods).

Definition at line 158 of file MouseEvent.java.

◆ getX() [1/2]

final int com.jogamp.newt.event.MouseEvent.getX ( )

See details for multiple-pointer events.

Returns
X-Coord of the triggering pointer-index zero in pixel units.

Definition at line 357 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getX() [2/2]

final int com.jogamp.newt.event.MouseEvent.getX ( final int  index)

See details for multiple-pointer events.

Parameters
indexpointer-index within [0 .. getPointerCount()-1]
Returns
X-Coord associated with the pointer-index in pixel units.
See also
getPointerId(index)

Definition at line 375 of file MouseEvent.java.

◆ getY() [1/2]

final int com.jogamp.newt.event.MouseEvent.getY ( )

See details for multiple-pointer events.

Returns
Y-Coord of the triggering pointer-index zero in pixel units.

Definition at line 365 of file MouseEvent.java.

Here is the caller graph for this function:

◆ getY() [2/2]

final int com.jogamp.newt.event.MouseEvent.getY ( final int  index)

See details for multiple-pointer events.

Parameters
indexpointer-index within [0 .. getPointerCount()-1]
Returns
Y-Coord associated with the pointer-index in pixel units.
See also
getPointerId(index)

Definition at line 385 of file MouseEvent.java.

◆ toString() [1/2]

final String com.jogamp.newt.event.MouseEvent.toString ( )

Reimplemented from com.jogamp.newt.event.InputEvent.

Definition at line 514 of file MouseEvent.java.

◆ toString() [2/2]

final StringBuilder com.jogamp.newt.event.MouseEvent.toString ( StringBuilder  sb)

Reimplemented from com.jogamp.newt.event.InputEvent.

Definition at line 519 of file MouseEvent.java.

Member Data Documentation

◆ BUTTON1

final short com.jogamp.newt.event.MouseEvent.BUTTON1 = 1
static

ID for button 1, value 1

Definition at line 136 of file MouseEvent.java.

◆ BUTTON2

final short com.jogamp.newt.event.MouseEvent.BUTTON2 = 2
static

ID for button 2, value 2

Definition at line 138 of file MouseEvent.java.

◆ BUTTON3

final short com.jogamp.newt.event.MouseEvent.BUTTON3 = 3
static

ID for button 3, value 3

Definition at line 140 of file MouseEvent.java.

◆ BUTTON4

final short com.jogamp.newt.event.MouseEvent.BUTTON4 = 4
static

ID for button 4, value 4

Definition at line 142 of file MouseEvent.java.

◆ BUTTON5

final short com.jogamp.newt.event.MouseEvent.BUTTON5 = 5
static

ID for button 5, value 5

Definition at line 144 of file MouseEvent.java.

◆ BUTTON6

final short com.jogamp.newt.event.MouseEvent.BUTTON6 = 6
static

ID for button 6, value 6

Definition at line 146 of file MouseEvent.java.

◆ BUTTON7

final short com.jogamp.newt.event.MouseEvent.BUTTON7 = 7
static

ID for button 6, value 7

Definition at line 148 of file MouseEvent.java.

◆ BUTTON8

final short com.jogamp.newt.event.MouseEvent.BUTTON8 = 8
static

ID for button 6, value 8

Definition at line 150 of file MouseEvent.java.

◆ BUTTON9

final short com.jogamp.newt.event.MouseEvent.BUTTON9 = 9
static

ID for button 6, value 9

Definition at line 152 of file MouseEvent.java.

◆ BUTTON_COUNT

final short com.jogamp.newt.event.MouseEvent.BUTTON_COUNT = 16
static

Maximum number of buttons, value 16

Definition at line 155 of file MouseEvent.java.

◆ EVENT_MOUSE_CLICKED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED = 200
static

Definition at line 586 of file MouseEvent.java.

◆ EVENT_MOUSE_DRAGGED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED = 206
static

Definition at line 594 of file MouseEvent.java.

◆ EVENT_MOUSE_ENTERED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED = 201
static

Only generated for PointerType#Mouse.

Definition at line 588 of file MouseEvent.java.

◆ EVENT_MOUSE_EXITED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED = 202
static

Only generated for PointerType#Mouse.

Definition at line 590 of file MouseEvent.java.

◆ EVENT_MOUSE_MOVED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED = 205
static

Definition at line 593 of file MouseEvent.java.

◆ EVENT_MOUSE_PRESSED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED = 203
static

Definition at line 591 of file MouseEvent.java.

◆ EVENT_MOUSE_RELEASED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED = 204
static

Definition at line 592 of file MouseEvent.java.

◆ EVENT_MOUSE_WHEEL_MOVED

final short com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED = 207
static

Definition at line 595 of file MouseEvent.java.


The documentation for this class was generated from the following file: