Top Description Inners Fields Constructors Methods
com.jogamp.newt.event

public Class MouseEvent

extends InputEvent
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
java.util.Arrays

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
MouseEvent.PointerClass

Class of pointer types

public static enum
MouseEvent.PointerType

Type of pointer devices

Field Summary

Modifier and TypeField and Description
private final short
button

Returns the button number, e.g. [BUTTON1..

public static final short
BUTTON1

ID for button 1, value 1

public static final short
BUTTON2

ID for button 2, value 2

public static final short
BUTTON3

ID for button 3, value 3

public static final short
BUTTON4

ID for button 4, value 4

public static final short
BUTTON5

ID for button 5, value 5

public static final short
BUTTON6

ID for button 6, value 6

public static final short
BUTTON7

ID for button 6, value 7

public static final short
BUTTON8

ID for button 6, value 8

public static final short
BUTTON9

ID for button 6, value 9

public static final short
BUTTON_COUNT

Maximum number of buttons, value 16

private final short
private static final MouseEvent.PointerType[]
private static final float[]
private static final float[]
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
private final float
private final short[]
pointerID

Pointer-ID for each pointer (multiple pointer).

private final MouseEvent.PointerType[]
pointerType

PointerType for each pointer (multiple pointer)

private final float[]
pressure

Pressure for each pointer (multiple pointer)

private final float
rotationScale

Rotation scale

private final float[]
rotationXYZ

Rotation around the X, Y and X axis

private final int[]
x

X-axis for each pointer (multiple pointer)

private final int[]
y

Y-axis for each pointer (multiple pointer)

Inherited from com.jogamp.newt.event.InputEvent:
ALT_GRAPH_MASKALT_MASKAUTOREPEAT_MASKBUTTON1_MASKBUTTON2_MASKBUTTON3_MASKBUTTON4_MASKBUTTON5_MASKBUTTON6_MASKBUTTON7_MASKBUTTON8_MASKBUTTON9_MASKBUTTONALL_MASKBUTTONLAST_MASKCONFINED_MASKCTRL_MASKINVISIBLE_MASKMETA_MASKSHIFT_MASK

Constructor Summary

AccessConstructor and Description
public
MouseEvent(final short eventType, final Object source, final long when, final int modifiers, final int
X-axis
x
,
final int
Y-axis
y
,
final short
Mouse-button click-count
clickCount
,
final short
button number, e.g. [BUTTON1..BUTTON_COUNT-1]. A button value of 0 denotes no button activity, i.e. PointerType#Mouse move.
button
,
final float[]
Rotation of all axis
rotationXYZ
,
final float
Rotation scale
rotationScale
)

Constructor for traditional one-pointer event.

public
MouseEvent(final short eventType, final Object source, final long when, final int modifiers, final MouseEvent.PointerType[]
PointerType for each pointer (multiple pointer)
pointerType
,
final short[]
Pointer 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.
pointerID
,
final int[]
X-axis for each pointer (multiple pointer)
x
,
final int[]
Y-axis for each pointer (multiple pointer)
y
,
final float[]
Pressure for each pointer (multiple pointer)
pressure
,
final float
Maximum pointer pressure for all pointer
maxPressure
,
final short
Corresponding mouse-button
button
,
final short
Mouse-button click-count
clickCount
,
final float[]
Rotation of all axis
rotationXYZ
,
final float
Rotation scale
rotationScale
)

Constructor for a multiple-pointer event.

Method Summary

Modifier and TypeMethod and Description
public final MouseEvent
createVariant(final short newEventType)

public final short[]

Returns:

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

See details for multiple-pointer events.

public final MouseEvent.PointerType[]

Returns:

array of all PointerTypes for all pointers
getAllPointerTypes
()

See details for multiple-pointer events.

public final float[]

Returns:

array of all raw, un-normalized pressures for all pointers
getAllPressures
()

See details for multiple-pointer events.

public final int[]

Returns:

array of all X-Coords for all pointers in pixel units.
getAllX
()

See details for multiple-pointer events.

public final int[]

Returns:

array of all Y-Coords for all pointers in pixel units.
getAllY
()

See details for multiple-pointer events.

public final short
getButton()

Returns the button number, e.g. [BUTTON1..

public final short
public static final short
public static String
getEventTypeString(final short type)

public final float
getMaxPressure()

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

public final int

Returns:

the count of pointers involved in this event
getPointerCount
()

See details for multiple-pointer events.

public final short
getPointerId(final int index)

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

public final int

Returns:

the pointer index for the given pointer id or -1 if id not available.
getPointerIdx
(final short id)

See details for multiple-pointer events.

public final MouseEvent.PointerType

Returns:

the PointerType for the data at index or null if index not available.
getPointerType
(final int index)

See details for multiple-pointer events.

public final float

Returns:

The pressure associated with the pointer-index 0. The value of zero is return if not available.
getPressure
(final boolean
if true, method returns the normalized pressure, i.e. pressure / maxPressure
normalized
)

public final float

Returns:

The pressure associated with the pointer-index. The value of zero is return if not available.
getPressure
(final int
pointer-index within [0 .. getPointerCount()-1]
index
,
final boolean
if true, method returns the normalized pressure, i.e. pressure / maxPressure
normalized
)

See details for multiple-pointer events.

public 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.

public final float
getRotationScale()

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

public 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).

public final int

Returns:

X-Coord of the triggering pointer-index zero in pixel units.
getX
()

See details for multiple-pointer events.

public final int

Returns:

X-Coord associated with the pointer-index in pixel units.
getX
(final int
pointer-index within [0 .. getPointerCount()-1]
index
)

See details for multiple-pointer events.

public final int

Returns:

Y-Coord of the triggering pointer-index zero in pixel units.
getY
()

See details for multiple-pointer events.

public final int

Returns:

Y-Coord associated with the pointer-index in pixel units.
getY
(final int
pointer-index within [0 .. getPointerCount()-1]
index
)

See details for multiple-pointer events.

public final String
toString()

Overrides com.jogamp.newt.event.InputEvent.toString.

Returns a String representation of this EventObject.
public final StringBuilder
Inherited from com.jogamp.newt.event.InputEvent:
getButtonDownCountgetButtonMaskgetButtonsDowngetModifiersgetModifiersStringisAltDownisAltGraphDownisAnyButtonDownisAutoRepeatisButtonDownisConfinedisControlDownisInvisibleisMetaDownisShiftDown

Field Detail

buttonback to summary
private final short button

Returns the button number, e.g. [BUTTON1..BUTTON_COUNT-1].

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

BUTTON1back to summary
public static final short BUTTON1

ID for button 1, value 1

BUTTON2back to summary
public static final short BUTTON2

ID for button 2, value 2

BUTTON3back to summary
public static final short BUTTON3

ID for button 3, value 3

BUTTON4back to summary
public static final short BUTTON4

ID for button 4, value 4

BUTTON5back to summary
public static final short BUTTON5

ID for button 5, value 5

BUTTON6back to summary
public static final short BUTTON6

ID for button 6, value 6

BUTTON7back to summary
public static final short BUTTON7

ID for button 6, value 7

BUTTON8back to summary
public static final short BUTTON8

ID for button 6, value 8

BUTTON9back to summary
public static final short BUTTON9

ID for button 6, value 9

BUTTON_COUNTback to summary
public static final short BUTTON_COUNT

Maximum number of buttons, value 16

clickCountback to summary
private final short clickCount
constMousePointerTypesback to summary
private static final MouseEvent.PointerType[] constMousePointerTypes
constMousePressure0back to summary
private static final float[] constMousePressure0
constMousePressure1back to summary
private static final float[] constMousePressure1
EVENT_MOUSE_CLICKEDback to summary
public static final short EVENT_MOUSE_CLICKED
EVENT_MOUSE_DRAGGEDback to summary
public static final short EVENT_MOUSE_DRAGGED
EVENT_MOUSE_ENTEREDback to summary
public static final short EVENT_MOUSE_ENTERED

Only generated for PointerType#Mouse

EVENT_MOUSE_EXITEDback to summary
public static final short EVENT_MOUSE_EXITED

Only generated for PointerType#Mouse

EVENT_MOUSE_MOVEDback to summary
public static final short EVENT_MOUSE_MOVED
EVENT_MOUSE_PRESSEDback to summary
public static final short EVENT_MOUSE_PRESSED
EVENT_MOUSE_RELEASEDback to summary
public static final short EVENT_MOUSE_RELEASED
EVENT_MOUSE_WHEEL_MOVEDback to summary
public static final short EVENT_MOUSE_WHEEL_MOVED
maxPressureback to summary
private final float maxPressure
pointerIDback to summary
private final short[] pointerID

Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers.

pointerTypeback to summary
private final MouseEvent.PointerType[] pointerType

PointerType for each pointer (multiple pointer)

pressureback to summary
private final float[] pressure

Pressure for each pointer (multiple pointer)

rotationScaleback to summary
private final float rotationScale

Rotation scale

rotationXYZback to summary
private final float[] rotationXYZ

Rotation around the X, Y and X axis

xback to summary
private final int[] x

X-axis for each pointer (multiple pointer)

yback to summary
private final int[] y

Y-axis for each pointer (multiple pointer)

Constructor Detail

MouseEventback to summary
public 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
x:int

X-axis

y:int

Y-axis

clickCount:short

Mouse-button click-count

button:short

button number, e.g. [BUTTON1..BUTTON_COUNT-1]. A button value of 0 denotes no button activity, i.e. PointerType#Mouse move.

rotationXYZ:float[]

Rotation of all axis

rotationScale:float

Rotation scale

MouseEventback to summary
public MouseEvent(final short eventType, final Object source, final long when, final int modifiers, final MouseEvent.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
pointerType:MouseEvent.PointerType[]

PointerType for each pointer (multiple pointer)

pointerID:short[]

Pointer 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.

x:int[]

X-axis for each pointer (multiple pointer)

y:int[]

Y-axis for each pointer (multiple pointer)

pressure:float[]

Pressure for each pointer (multiple pointer)

maxPressure:float

Maximum pointer pressure for all pointer

button:short

Corresponding mouse-button

clickCount:short

Mouse-button click-count

rotationXYZ:float[]

Rotation of all axis

rotationScale:float

Rotation scale

Method Detail

createVariantback to summary
public final MouseEvent createVariant(final short newEventType)
getAllPointerIDsback to summary
public final short[] getAllPointerIDs()

See details for multiple-pointer events.

Returns:short[]

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

getAllPointerTypesback to summary
public final MouseEvent.PointerType[] getAllPointerTypes()

See details for multiple-pointer events.

Returns:MouseEvent.PointerType[]

array of all PointerTypes for all pointers

getAllPressuresback to summary
public final float[] getAllPressures()

See details for multiple-pointer events.

Returns:float[]

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

getAllXback to summary
public final int[] getAllX()

See details for multiple-pointer events.

Returns:int[]

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

getAllYback to summary
public final int[] getAllY()

See details for multiple-pointer events.

Returns:int[]

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

getButtonback to summary
public final short 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.

getClickCountback to summary
public final short getClickCount()
getClickTimeoutback to summary
public static final short getClickTimeout()
getEventTypeStringback to summary
public static String getEventTypeString(final short type)
getMaxPressureback to summary
public final float 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

getPointerCountback to summary
public final int getPointerCount()

See details for multiple-pointer events.

Returns:int

the count of pointers involved in this event

getPointerIdback to summary
public final short 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.

getPointerIdxback to summary
public final int getPointerIdx(final short id)

See details for multiple-pointer events.

Returns:int

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

getPointerTypeback to summary
public final MouseEvent.PointerType getPointerType(final int index)

See details for multiple-pointer events.

Returns:MouseEvent.PointerType

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

getPressureback to summary
public final float getPressure(final boolean normalized)
Parameters
normalized:boolean

if true, method returns the normalized pressure, i.e. pressure / maxPressure

Returns:float

The pressure associated with the pointer-index 0. The value of zero is return if not available.

See Also
getMaxPressure()
getPressureback to summary
public final float getPressure(final int index, final boolean normalized)

See details for multiple-pointer events.

Parameters
index:int

pointer-index within [0 .. getPointerCount()-1]

normalized:boolean

if true, method returns the normalized pressure, i.e. pressure / maxPressure

Returns:float

The pressure associated with the pointer-index. The value of zero is return if not available.

See Also
getMaxPressure()
getRotationback to summary
public 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.

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.

getRotationScaleback to summary
public final float 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.

getRotationXYZback to summary
public 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).

getXback to summary
public final int getX()

See details for multiple-pointer events.

Returns:int

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

getXback to summary
public final int getX(final int index)

See details for multiple-pointer events.

Parameters
index:int

pointer-index within [0 .. getPointerCount()-1]

Returns:int

X-Coord associated with the pointer-index in pixel units.

See Also
getPointerId(index)
getYback to summary
public final int getY()

See details for multiple-pointer events.

Returns:int

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

getYback to summary
public final int getY(final int index)

See details for multiple-pointer events.

Parameters
index:int

pointer-index within [0 .. getPointerCount()-1]

Returns:int

Y-Coord associated with the pointer-index in pixel units.

See Also
getPointerId(index)
toStringback to summary
public final String toString()

Overrides com.jogamp.newt.event.InputEvent.toString.

Doc from java.util.EventObject.toString.

Returns a String representation of this EventObject.

Returns:String

a String representation of this EventObject

Annotations
@Override
toStringback to summary
public final StringBuilder toString(StringBuilder sb)

Overrides com.jogamp.newt.event.InputEvent.toString.

Annotations
@Override
com.jogamp.newt.event back to summary

public final Enum MouseEvent.PointerClass

extends Enum<MouseEvent.PointerClass>
implements InputClass
Class Inheritance
All Implemented Interfaces
com.jogamp.newt.event.InputEvent.InputClass

Class of pointer types

Field Summary

Modifier and TypeField and Description
public static final MouseEvent.PointerClass
public static final MouseEvent.PointerClass
public static final MouseEvent.PointerClass

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static MouseEvent.PointerClass
public static MouseEvent.PointerClass[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Offscreenback to summary
public static final MouseEvent.PointerClass Offscreen
Onscreenback to summary
public static final MouseEvent.PointerClass Onscreen
Undefinedback to summary
public static final MouseEvent.PointerClass Undefined

Constructor Detail

PointerClassback to summary
private PointerClass()

Method Detail

valueOfback to summary
public static MouseEvent.PointerClass valueOf(String name)
valuesback to summary
public static MouseEvent.PointerClass[] values()
com.jogamp.newt.event back to summary

public final Enum MouseEvent.PointerType

extends Enum<MouseEvent.PointerType>
implements InputType
Class Inheritance
All Implemented Interfaces
com.jogamp.newt.event.InputEvent.InputType

Type of pointer devices

Field Summary

Modifier and TypeField and Description
public static final MouseEvent.PointerType
pack-priv MouseEvent.PointerClass
public static final MouseEvent.PointerType
Pen

PointerClass#Onscreen pen usually on screen?

public static final MouseEvent.PointerType
TouchPad

PointerClass#Offscreen touch pad, usually using fingers.

public static final MouseEvent.PointerType
TouchScreen

PointerClass#Onscreen touch screen, usually using fingers.

public static final MouseEvent.PointerType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MouseEvent.PointerClass
public static MouseEvent.PointerType
public static MouseEvent.PointerType
valueOf(final int ordinal)

Returns the matching PointerType value corresponding to the given PointerType's integer ordinal.

public static MouseEvent.PointerType[]
public static MouseEvent.PointerType[]
valuesOf(final int[] ordinals)

Returns the PointerType array of matching PointerType values corresponding to the given PointerType's integer ordinal values.

Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Mouseback to summary
public static final MouseEvent.PointerType Mouse

PointerClass#Offscreen mouse. Ordinal 0.

pcback to summary
pack-priv MouseEvent.PointerClass pc
Penback to summary
public static final MouseEvent.PointerType Pen

PointerClass#Onscreen pen usually on screen? Ordinal 3. FIXME

TouchPadback to summary
public static final MouseEvent.PointerType TouchPad

PointerClass#Offscreen touch pad, usually using fingers. Ordinal 1.

TouchScreenback to summary
public static final MouseEvent.PointerType TouchScreen

PointerClass#Onscreen touch screen, usually using fingers. Ordinal 2.

Undefinedback to summary
public static final MouseEvent.PointerType Undefined

PointerClass#Undefined ?. Ordinal 4.

Constructor Detail

PointerTypeback to summary
private PointerType(final MouseEvent.PointerClass pc)

Method Detail

getPointerClassback to summary
public MouseEvent.PointerClass getPointerClass()
valueOfback to summary
public static MouseEvent.PointerType valueOf(String name)
valueOfback to summary
public static MouseEvent.PointerType valueOf(final int ordinal) throws IllegalArgumentException

Returns the matching PointerType value corresponding to the given PointerType's integer ordinal.

  given:
    ordinal = enumValue.ordinal()
  reverse:
    enumValue = EnumClass.values()[ordinal]
Exceptions
IllegalArgumentException:
if the given ordinal is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ]
valuesback to summary
public static MouseEvent.PointerType[] values()
valuesOfback to summary
public static MouseEvent.PointerType[] valuesOf(final int[] ordinals) throws IllegalArgumentException

Returns the PointerType array of matching PointerType values corresponding to the given PointerType's integer ordinal values.

See valueOf(int).

Exceptions
IllegalArgumentException:
if one of the given ordinal values is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ]