PointerEvent
Class
Common
expect class PointerEvent
internal constructor(
changes: List<PointerInputChange>,
internalPointerEvent: InternalPointerEvent?,
)
Describes a pointer input change event that has occurred at a particular point in time.
Secondary Constructors
constructor(changes: List<PointerInputChange>)
Parameters
changes | The changes. |
Properties
Common
val changes: List<PointerInputChange>
The changes.
Common
val buttons: PointerButtons
The state of buttons (e.g. mouse or stylus buttons) during this event.
Common
val keyboardModifiers: PointerKeyboardModifiers
The state of modifier keys during this event.
Common
var type: PointerEventType
The primary reason the PointerEvent
was sent.
Android
actual class PointerEvent
internal actual constructor(
/** The changes. */
actual val changes: List<PointerInputChange>,
internal val internalPointerEvent: InternalPointerEvent?,
)
Describes a pointer input change event that has occurred at a particular point in time.
Secondary Constructors
actual constructor(changes: List<PointerInputChange>) : this(changes, null)
Parameters
changes | The changes. |
Properties
Android
val motionEvent: MotionEvent?
The underlying Android MotionEvent
that triggered this PointerEvent
.
This property provides access to the raw MotionEvent
for retrieving platform-specific
information not yet exposed by the Compose PointerEvent
API (e.g., stylus tilt angle).
Important Considerations:
- Read-Only: The returned
MotionEvent
is strictly read-only. Modifying it will lead to unpredictable behavior. - Transient: Do not store a reference to this
MotionEvent
. The Android framework may recycle it, rendering its state undefined and causing errors if accessed later. Access the data only within the scope where thePointerEvent
is received. - Metadata Only: This
MotionEvent
should not be used for primary input handling logic (e.g., determining pointer position or button presses). Rely on the properties ofPointerEvent
andPointerInputChange
for this purpose. TheMotionEvent
is intended solely for accessing supplemental metadata. - Nullability: This property will be
null
in two cases: * ThePointerEvent
was fabricated within Compose (i.e., not directly from a system input event). * ThePointerEvent
has already been dispatched within the Compose input system. (Seeandroidx.compose.ui.samples.PointerEventMotionEventSample
for details).
Android
@get:MotionEventClassification
val classification: Int
Returns
``MotionEvent's classification
(https://developer.android.com/reference/android/view/MotionEvent#getClassification()).
Android
actual val buttons = PointerButtons(motionEvent?.buttonState ?: 0)
Android
actual val keyboardModifiers = PointerKeyboardModifiers(motionEvent?.metaState ?: 0)
Android
actual var type: PointerEventType
Functions
fun component1(): List<PointerInputChange>
fun copy(changes: List<PointerInputChange>, motionEvent: MotionEvent?): PointerEvent