Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
PointerEvent Class Reference

Pointer event. More...

#include <PointerEvent.h>

Inherits Event.

Public Member Functions

 PointerEvent ()
 Constructor.
Vec2 getPoint () const
 Returns the current touch location in screen coordinates.
Vec2 getPrevPoint () const
 Returns the previous touch location in screen coordinates.
Vec2 getStartPoint () const
 Returns the start touch location in screen coordinates.
Vec2 getWorldPoint () const
 Returns the current pointer position in world space.
Vec2 getPrevWorldPoint () const
 Returns the previous pointer position in world space.
Vec2 getStartWorldPoint () const
 Returns the start pointer position in world space.
const Vec2 & getScrollDelta () const
 Get mouse scroll data of axis.
intptr_t getPointerId () const
 Get pointer id.
PointerType getPointerType () const
 Get the pointer device type for this event.
int getButton () const
 Get the index of the button that triggered this event.
uint32_t getPressedButtons () const
 Get the bitmask of currently pressed buttons.
bool isButtonPressed (int buttonIndex) const
 Check whether specified button index pressed.
bool isPrimaryPressed () const
 Checks if the primary input is currently pressed.
bool isCaptured () const
 Checks whether this event was routed through pointer capture.
float getPressure () const
 Returns the normalized pressure applied to the touch surface.
InputPhase getPhase () const
 Get the phase of this pointer event.
bool isPrimary () const
 Indicates whether this pointer is the primary pointer.
void setPointerInfo (InputPhase phase, Vec2 point, const PointerInputState &inputState)
 Set the touch information.
void setScrollData (Vec2 delta)
 Set mouse scroll data.
Public Member Functions inherited from Event
 Event (Type type)
 Constructor.
virtual ~Event ()
 Destructor.
Type getType () const
 Gets the event type.
void stopPropagation ()
 Stops propagation for current event.
bool isStopped () const
 Checks whether the event has been stopped.
Node * getCurrentTarget ()
 Gets current target of the event.
Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
void release ()
 Releases the ownership immediately.
Object * autorelease ()
 Releases the ownership sometime soon automatically.
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
uint64_t getObjectID () const noexcept
 Returns the process-local diagnostic identifier assigned at construction.
virtual ~Object ()
 Destructor.

Additional Inherited Members

Public Types inherited from Event
enum class  Type
 Type Event type.

Detailed Description

Pointer event.

Member Function Documentation

◆ getPoint()

Vec2 getPoint ( ) const

Returns the current touch location in screen coordinates.

Returns
The current touch location in screen coordinates.

◆ getPrevPoint()

Vec2 getPrevPoint ( ) const

Returns the previous touch location in screen coordinates.

Returns
The previous touch location in screen coordinates.

◆ getStartPoint()

Vec2 getStartPoint ( ) const

Returns the start touch location in screen coordinates.

Returns
The start touch location in screen coordinates.

◆ getWorldPoint()

Vec2 getWorldPoint ( ) const

Returns the current pointer position in world space.

Uses the per-camera ray (set by EventDispatcher) to compute the correct world point for the camera that performed the hit-test.

◆ getScrollDelta()

const Vec2 & getScrollDelta ( ) const
inline

Get mouse scroll data of axis.

Returns
The scroll data of axis.

◆ getPointerId()

intptr_t getPointerId ( ) const
inline

Get pointer id.

@lua getId

Returns
The id of pointer.

◆ getPointerType()

PointerType getPointerType ( ) const
inline

Get the pointer device type for this event.

Returns the type of pointer that produced the event (for example, Mouse, Touch, or Pen).

Returns
PointerType The pointer device type.

◆ getButton()

int getButton ( ) const
inline

Get the index of the button that triggered this event.

The value is a button index (0..n-1) when a physical button triggered the event. Use -1 to indicate "no button" (for example, touch events or pure move events).

Returns
int The triggering button index, or -1 if none.
Note
This field represents the single button that caused this event. To inspect the current set of pressed buttons, use getPressedButtons().

◆ getPressedButtons()

uint32_t getPressedButtons ( ) const
inline

Get the bitmask of currently pressed buttons.

Each bit corresponds to a button index: bit i represents whether button index i is currently pressed (1 = pressed, 0 = released). For example, bit 0 = left button, bit 1 = right button, bit 2 = middle button.

Returns
uint32_t Bitmask of pressed buttons; 0 means no buttons pressed.
Note
The mapping between button indices and bits is: bit i <-> button index i. For touch events, this value is typically 0.

◆ isPrimaryPressed()

bool isPrimaryPressed ( ) const

Checks if the primary input is currently pressed.

This method returns true when the primary input source is actively pressed and not in the PointerUp phase.

  • Mouse: True if the primary button (typically the left button) is pressed.
  • Touch: True if the first touch point is active (touch down).
  • Pen: True if the pen tip (primary button) is pressed.

Use this method to detect the main interaction across devices (mouse left drag, first finger touch drag, or pen tip press).

Returns
True if the primary input is pressed, false otherwise.

◆ getPressure()

float getPressure ( ) const
inline

Returns the normalized pressure applied to the touch surface.

This value represents the force intensity of the touch, universally supported across multi-touch screens, digital styluses (e.g., Apple Pencil), and pressure-sensitive devices.

Returns
A normalized float value typically ranging from 0.0f to 1.0f:
  • 0.0f: No pressure applied or hovering.
  • 1.0f: Standard full press intensity.
  • Values > 1.0f may be returned on platforms supporting deep press (e.g., iOS 3D Touch).
Note
For legacy devices or platforms lacking pressure-sensing hardware, this safely falls back to a constant 1.0f to guarantee standard touch interactions.

◆ getPhase()

InputPhase getPhase ( ) const
inline

Get the phase of this pointer event.

Returns the input phase that describes the current state of the pointer interaction, such as when a mouse button, touch, or pen contact is pressed, released, moved, or canceled.

Returns
InputPhase enumeration value indicating the event phase:
  • InputPhase::PointerDown when the pointer makes contact
  • InputPhase::PointerUp when the pointer contact ends
  • InputPhase::PointerMove when the pointer moves
  • InputPhase::PointerCancel when the pointer interaction is canceled
  • InputPhase::PointerScroll when the pointer performs a scroll
Note
This reflects only the state of this PointerEvent instance and does not query the global pointer state.

◆ isPrimary()

bool isPrimary ( ) const
inline

Indicates whether this pointer is the primary pointer.

Returns true if the pointer is considered primary. The primary pointer is the one that controls the mouse cursor. For touch input, the first finger that touches the screen is marked as primary. For mouse input, the pointer is always primary.

Returns
True if this is the primary pointer, false otherwise.

◆ setPointerInfo()

void setPointerInfo ( InputPhase phase,
Vec2 point,
const PointerInputState & inputState )

Set the touch information.

It always used to monitor touch event.

Parameters
idA given id
pointA given point in screen coordinate.
pressuremaximum possible force for 3d touch.

◆ setScrollData()

void setScrollData ( Vec2 delta)
inline

Set mouse scroll data.

Parameters
scrollXThe scroll data of x axis.
scrollYThe scroll data of y axis.

The documentation for this class was generated from the following file:
  • PointerEvent.h