androidx.compose.ui.input.pointer

Interfaces

AwaitPointerEventScope

Receiver scope for awaiting pointer events in a call to PointerInputScope.awaitPointerEventScope.

Cmn
PointerIcon

Represents a pointer icon to use in Modifier.pointerHoverIcon or Modifier.stylusHoverIcon.

Cmn
PointerInputEventHandler
Cmn
PointerInputModifier

A Modifier.Element that can interact with pointer input.

Cmn
PointerInputScope

Receiver scope for Modifier.pointerInput that permits handling pointer input.

Cmn
SuspendingPointerInputModifierNode

Extends PointerInputModifierNode with a handler to execute asynchronously when an event occurs and a function to reset that handler (cancels the existing coroutine and essentially resets the handler's execution).

Cmn

Classes

ConsumedData

This class is deprecated. Use PointerInputChange.isConsumed and PointerInputChange.consume() instead

Cmn
HistoricalChange

Data structure for "historical" pointer moves.

Cmn
NativePointerButtons
Cmn
NativePointerKeyboardModifiers
Cmn
PointerButtons

Contains the state of pointer buttons (e.g. mouse and stylus buttons).

Cmn
PointerEvent

Describes a pointer input change event that has occurred at a particular point in time.

Cmn
android
PointerEventType

Indicates the primary reason that the PointerEvent was sent.

Cmn
PointerId

An ID for a given pointer.

Cmn
PointerInputChange

Describes a change that has occurred for a particular pointer, as well as how much of the change has been consumed (meaning, used by a node in the UI).

Cmn
PointerInputFilter

A PointerInputFilter represents a single entity that receives PointerInputChanges), interprets them, and consumes the aspects of the changes that it is react to such that other PointerInputFilters don't also react to them.

Cmn
PointerKeyboardModifiers

Contains the state of modifier keys, such as Shift, Control, and Alt, as well as the state of the lock keys, such as Caps Lock and Num Lock.

Cmn
PointerType

The device type that produces a PointerInputChange, such as a mouse or stylus.

Cmn
RequestDisallowInterceptTouchEvent

Function that can be passed to pointerInteropFilter and then later invoked which provides an analog to ViewParent.requestDisallowInterceptTouchEvent.

android

Exceptions

PointerEventTimeoutCancellationException

An exception thrown from AwaitPointerEventScope.withTimeout when the execution time of the coroutine is too long.

Cmn
android

Enums

PointerEventPass

The enumeration of passes where PointerInputChange traverses up and down the UI tree.

Cmn

Modifiers

motionEventSpy

Calls watcher with each MotionEvent that the layout area or any child pointerInput receives.

android
pointerHoverIcon

Modifier that lets a developer define a pointer icon to display when the cursor is hovered over the element.

Cmn
pointerInput

Create a modifier for processing pointer input within the region of the modified element.

Cmn
pointerInteropFilter

A special PointerInputModifier that provides access to the underlying MotionEvents originally dispatched to Compose.

android
stylusHoverIcon

Modifier that lets a developer define a pointer icon to display when a stylus is hovered over the element.

Cmn

Top-level functions summary

PointerIcon
PointerIcon(pointerIcon: PointerIcon)

Creates PointerIcon from android.view.PointerIcon

android
PointerIcon
PointerIcon(pointerIconType: Int)

Creates PointerIcon from pointer icon type (see android.view.PointerIcon.getSystemIcon

android
SuspendingPointerInputModifierNode

Supports suspending pointer event handling.

Cmn

Extension functions summary

Boolean

This function is deprecated. Partial consumption has been deprecated.

Cmn
Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen and that change has not been consumed.

Cmn
Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen, whether or not that change has been consumed.

Cmn
Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen and that change has not been consumed.

Cmn
Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen, whether or not that change has been consumed.

Cmn
Unit

This function is deprecated. Use consume() instead

Cmn
Unit

This function is deprecated. Partial consumption has been deprecated.

Cmn
Unit

This function is deprecated. Partial consumption has been deprecated.

Cmn
Int

Returns the index of first button pressed as used in isPressed or -1 if no button is pressed.

Cmn
android
Int

Returns the index of last button pressed as used in isPressed or -1 if no button is pressed.

Cmn
android
Boolean

This function is deprecated. Use isOutOfBounds() that supports minimum touch target

Cmn
Boolean
PointerInputChange.isOutOfBounds(
    size: IntSize,
    extendedTouchPadding: Size
)

Returns true if the pointer has moved outside of the pointer region.

Cmn
Boolean

Returns true when the button at buttonIndex is pressed and false when it isn't pressed.

Cmn
android
Offset

The distance that the pointer has moved on the screen minus any distance that has been consumed.

Cmn
Boolean

This function is deprecated. Partial consumption has been deprecated.

Cmn
Offset

The distance that the pointer has moved on the screen, ignoring the fact that it might have been consumed.

Cmn
Boolean

True if this PointerInputChange represents a pointer moving on the screen and some of that movement has not been consumed.

Cmn
Boolean

True if this PointerInputChange represents a pointer moving on the screen ignoring how much of that movement may have been consumed.

Cmn

Extension properties summary

Boolean

Returns true if any button is pressed or false if all buttons are released.

Cmn
android
Boolean

true when the AltGraph key is pressed.

Cmn
android
Boolean

true when the Alt key is pressed.

Cmn
android
Boolean

true when the back button (mouse back button) is pressed or false when it isn't pressed or there is no mouse button assigned to "back."

Cmn
android
Boolean

true when the keyboard's Caps Lock is on.

Cmn
android
Boolean

true when the Control key is pressed.

Cmn
android
Boolean

true when the forward button (mouse forward button) is pressed or false when it isn't pressed or there is no button assigned to "forward."

Cmn
android
Boolean

true when the Function key is pressed.

Cmn
android
Boolean

true when the Meta key is pressed.

Cmn
android
Boolean

true when the keyboard's Num Lock is on.

Cmn
android
Boolean

true when the primary button (left mouse button) is pressed or false when it isn't pressed.

Cmn
android
Boolean

true when the keyboard's Scroll Lock is on.

Cmn
android
Boolean

true when the secondary button (right mouse button) is pressed or false when it isn't pressed.

Cmn
android
Boolean

true when the Shift key is pressed.

Cmn
android
Boolean

true when the Sym key is pressed.

Cmn
android
Boolean

true when the tertiary button (middle mouse button) is pressed or false when it isn't pressed.

Cmn
android

Top-level functions

PointerIcon

fun PointerIcon(pointerIcon: PointerIcon): PointerIcon

Creates PointerIcon from android.view.PointerIcon

PointerIcon

fun PointerIcon(pointerIconType: Int): PointerIcon

Creates PointerIcon from pointer icon type (see android.view.PointerIcon.getSystemIcon

SuspendingPointerInputModifierNode

fun SuspendingPointerInputModifierNode(
    pointerInputEventHandler: PointerInputEventHandler
): SuspendingPointerInputModifierNode

Supports suspending pointer event handling. This is used by pointerInput, so in most cases you should just use pointerInput for suspending pointer input. Creating a SuspendingPointerInputModifierNode should only be needed when you want to delegate to suspending pointer input as part of the implementation of a complex Modifier.Node.

Extension functions

PointerInputChange.anyChangeConsumed

fun PointerInputChange.anyChangeConsumed(): Boolean

True if any aspect of this PointerInputChange has been consumed.

PointerInputChange.changedToDown

fun PointerInputChange.changedToDown(): Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen and that change has not been consumed.

PointerInputChange.changedToDownIgnoreConsumed

fun PointerInputChange.changedToDownIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen, whether or not that change has been consumed.

PointerInputChange.changedToUp

fun PointerInputChange.changedToUp(): Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen and that change has not been consumed.

PointerInputChange.changedToUpIgnoreConsumed

fun PointerInputChange.changedToUpIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen, whether or not that change has been consumed.

PointerInputChange.consumeAllChanges

fun PointerInputChange.consumeAllChanges(): Unit

Consumes all changes associated with the PointerInputChange

PointerInputChange.consumeDownChange

fun PointerInputChange.consumeDownChange(): Unit

Consume the up or down change of this PointerInputChange if there is an up or down change to consume.

PointerInputChange.consumePositionChange

fun PointerInputChange.consumePositionChange(): Unit

Consume position change if there is any

PointerButtons.indexOfFirstPressed

fun PointerButtons.indexOfFirstPressed(): Int

Returns the index of first button pressed as used in isPressed or -1 if no button is pressed.

PointerButtons.indexOfLastPressed

fun PointerButtons.indexOfLastPressed(): Int

Returns the index of last button pressed as used in isPressed or -1 if no button is pressed.

PointerInputChange.isOutOfBounds

fun PointerInputChange.isOutOfBounds(size: IntSize): Boolean

Returns true if the pointer has moved outside of the region of (0, 0, size.width, size.height) or false if the current pointer is up or it is inside the given bounds.

PointerInputChange.isOutOfBounds

fun PointerInputChange.isOutOfBounds(
    size: IntSize,
    extendedTouchPadding: Size
): Boolean

Returns true if the pointer has moved outside of the pointer region. For Touch events, this is (-extendedTouchPadding.width, -extendedTouchPadding.height, size.width + extendedTouchPadding.width, size.height + extendedTouchPadding.height) and for other events, this is (0, 0, size.width, size.height). Returnsfalse if the current pointer is up or it is inside the pointer region.

PointerButtons.isPressed

fun PointerButtons.isPressed(buttonIndex: Int): Boolean

Returns true when the button at buttonIndex is pressed and false when it isn't pressed. This method can handle buttons that haven't been assigned a designated purpose like isPrimaryPressed and isSecondaryPressed.

PointerInputChange.positionChange

fun PointerInputChange.positionChange(): Offset

The distance that the pointer has moved on the screen minus any distance that has been consumed.

PointerInputChange.positionChangeConsumed

fun PointerInputChange.positionChangeConsumed(): Boolean

True if this PointerInputChange's movement has been consumed.

PointerInputChange.positionChangeIgnoreConsumed

fun PointerInputChange.positionChangeIgnoreConsumed(): Offset

The distance that the pointer has moved on the screen, ignoring the fact that it might have been consumed.

PointerInputChange.positionChanged

fun PointerInputChange.positionChanged(): Boolean

True if this PointerInputChange represents a pointer moving on the screen and some of that movement has not been consumed.

PointerInputChange.positionChangedIgnoreConsumed

fun PointerInputChange.positionChangedIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer moving on the screen ignoring how much of that movement may have been consumed.

Extension properties

PointerButtons.areAnyPressed

val PointerButtons.areAnyPressedBoolean

Returns true if any button is pressed or false if all buttons are released.

PointerKeyboardModifiers.isAltGraphPressed

val PointerKeyboardModifiers.isAltGraphPressedBoolean

true when the AltGraph key is pressed.

PointerKeyboardModifiers.isAltPressed

val PointerKeyboardModifiers.isAltPressedBoolean

true when the Alt key is pressed. This is commonly associated with the Option key on some keyboards.

PointerButtons.isBackPressed

val PointerButtons.isBackPressedBoolean

true when the back button (mouse back button) is pressed or false when it isn't pressed or there is no mouse button assigned to "back."

PointerKeyboardModifiers.isCapsLockOn

val PointerKeyboardModifiers.isCapsLockOnBoolean

true when the keyboard's Caps Lock is on.

PointerKeyboardModifiers.isCtrlPressed

val PointerKeyboardModifiers.isCtrlPressedBoolean

true when the Control key is pressed.

PointerButtons.isForwardPressed

val PointerButtons.isForwardPressedBoolean

true when the forward button (mouse forward button) is pressed or false when it isn't pressed or there is no button assigned to "forward."

PointerKeyboardModifiers.isFunctionPressed

val PointerKeyboardModifiers.isFunctionPressedBoolean

true when the Function key is pressed.

PointerKeyboardModifiers.isMetaPressed

val PointerKeyboardModifiers.isMetaPressedBoolean

true when the Meta key is pressed. This is commonly associated with the Windows or Command key on some keyboards.

PointerKeyboardModifiers.isNumLockOn

val PointerKeyboardModifiers.isNumLockOnBoolean

true when the keyboard's Num Lock is on.

PointerButtons.isPrimaryPressed

val PointerButtons.isPrimaryPressedBoolean

true when the primary button (left mouse button) is pressed or false when it isn't pressed.

PointerKeyboardModifiers.isScrollLockOn

val PointerKeyboardModifiers.isScrollLockOnBoolean

true when the keyboard's Scroll Lock is on.

PointerButtons.isSecondaryPressed

val PointerButtons.isSecondaryPressedBoolean

true when the secondary button (right mouse button) is pressed or false when it isn't pressed.

PointerKeyboardModifiers.isShiftPressed

val PointerKeyboardModifiers.isShiftPressedBoolean

true when the Shift key is pressed.

PointerKeyboardModifiers.isSymPressed

val PointerKeyboardModifiers.isSymPressedBoolean

true when the Sym key is pressed.

PointerButtons.isTertiaryPressed

val PointerButtons.isTertiaryPressedBoolean

true when the tertiary button (middle mouse button) is pressed or false when it isn't pressed.