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
changes
val changes: List<PointerInputChange>
The changes.
buttons
val buttons: PointerButtons
The state of buttons (e.g. mouse or stylus buttons) during this event.
keyboardModifiers
val keyboardModifiers: PointerKeyboardModifiers
The state of modifier keys during this event.
type
var type: PointerEventType
The primary reason the PointerEvent was sent.
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
motionEvent
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
MotionEventis 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 the PointerEvent is received. - Metadata Only: This
MotionEventshould not be used for primary input handling logic (e.g., determining pointer position or button presses). Rely on the properties of PointerEvent and PointerInputChange for this purpose. TheMotionEventis intended solely for accessing supplemental metadata. - Nullability: This property will be
nullin two cases: * The PointerEvent was fabricated within Compose (i.e., not directly from a system input event). * The PointerEvent has already been dispatched within the Compose input system. (See the sample code for details).
classification
@get:MotionEventClassification
val classification: Int
Returns MotionEvent's classification).
buttons
actual val buttons = PointerButtons(motionEvent?.buttonState ?: 0)
keyboardModifiers
actual val keyboardModifiers = PointerKeyboardModifiers(motionEvent?.metaState ?: 0)
type
actual var type: PointerEventType
Functions
component1
fun component1(): List<PointerInputChange>
copy
fun copy(changes: List<PointerInputChange>, motionEvent: MotionEvent?): PointerEvent