{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PointerEventKt

public final class PointerEventKt


Summary

Public methods

static final boolean

This method is deprecated. Partial consumption has been deprecated.

static final boolean

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

static final boolean

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

static final boolean

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

static final boolean

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

static final void

This method is deprecated. Use consume() instead

static final void

This method is deprecated. Partial consumption has been deprecated.

static final void

This method is deprecated. Partial consumption has been deprecated.

static final boolean

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

static final int

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

static final int

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

static final boolean

true when the AltGraph key is pressed.

static final boolean

true when the Alt key is pressed.

static final 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."

static final boolean

true when the keyboard's Caps Lock is on.

static final boolean

true when the Control key is pressed.

static final 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."

static final boolean

true when the Function key is pressed.

static final boolean

true when the Meta key is pressed.

static final boolean

true when the keyboard's Num Lock is on.

static final boolean

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

static final boolean
isOutOfBounds(
    @NonNull PointerInputChange receiver,
    @NonNull IntSize size,
    @NonNull Size extendedTouchPadding
)

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

static final boolean
isPressed(@NonNull PointerButtons receiver, int buttonIndex)

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

static final boolean

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

static final boolean

true when the keyboard's Scroll Lock is on.

static final boolean

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

static final boolean

true when the Shift key is pressed.

static final boolean

true when the Sym key is pressed.

static final boolean

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

static final @NonNull Offset

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

static final boolean

This method is deprecated. Partial consumption has been deprecated.

static final @NonNull Offset

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

static final boolean

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

static final boolean

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

Public methods

anyChangeConsumed

public static final boolean anyChangeConsumed(@NonNull PointerInputChange receiver)

True if any aspect of this PointerInputChange has been consumed.

changedToDown

public static final boolean changedToDown(@NonNull PointerInputChange receiver)

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

changedToDownIgnoreConsumed

public static final boolean changedToDownIgnoreConsumed(@NonNull PointerInputChange receiver)

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

changedToUp

public static final boolean changedToUp(@NonNull PointerInputChange receiver)

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

changedToUpIgnoreConsumed

public static final boolean changedToUpIgnoreConsumed(@NonNull PointerInputChange receiver)

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

consumeAllChanges

public static final void consumeAllChanges(@NonNull PointerInputChange receiver)

Consumes all changes associated with the PointerInputChange

consumeDownChange

public static final void consumeDownChange(@NonNull PointerInputChange receiver)

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

consumePositionChange

public static final void consumePositionChange(@NonNull PointerInputChange receiver)

Consume position change if there is any

getAreAnyPressed

public static final boolean getAreAnyPressed(@NonNull PointerButtons receiver)

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

indexOfFirstPressed

public static final int indexOfFirstPressed(@NonNull PointerButtons receiver)

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

indexOfLastPressed

public static final int indexOfLastPressed(@NonNull PointerButtons receiver)

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

isAltGraphPressed

public static final boolean isAltGraphPressed(@NonNull PointerKeyboardModifiers receiver)

true when the AltGraph key is pressed.

isAltPressed

public static final boolean isAltPressed(@NonNull PointerKeyboardModifiers receiver)

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

isBackPressed

public static final boolean isBackPressed(@NonNull PointerButtons receiver)

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

isCapsLockOn

public static final boolean isCapsLockOn(@NonNull PointerKeyboardModifiers receiver)

true when the keyboard's Caps Lock is on.

isCtrlPressed

public static final boolean isCtrlPressed(@NonNull PointerKeyboardModifiers receiver)

true when the Control key is pressed.

isForwardPressed

public static final boolean isForwardPressed(@NonNull PointerButtons receiver)

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

isFunctionPressed

public static final boolean isFunctionPressed(@NonNull PointerKeyboardModifiers receiver)

true when the Function key is pressed.

isMetaPressed

public static final boolean isMetaPressed(@NonNull PointerKeyboardModifiers receiver)

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

isNumLockOn

public static final boolean isNumLockOn(@NonNull PointerKeyboardModifiers receiver)

true when the keyboard's Num Lock is on.

isOutOfBounds

public static final boolean isOutOfBounds(@NonNull PointerInputChange receiver, @NonNull IntSize size)

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.

isOutOfBounds

public static final boolean isOutOfBounds(
    @NonNull PointerInputChange receiver,
    @NonNull IntSize size,
    @NonNull Size extendedTouchPadding
)

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.

isPressed

public static final boolean isPressed(@NonNull PointerButtons receiver, int buttonIndex)

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.

isPrimaryPressed

public static final boolean isPrimaryPressed(@NonNull PointerButtons receiver)

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

isScrollLockOn

public static final boolean isScrollLockOn(@NonNull PointerKeyboardModifiers receiver)

true when the keyboard's Scroll Lock is on.

isSecondaryPressed

public static final boolean isSecondaryPressed(@NonNull PointerButtons receiver)

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

isShiftPressed

public static final boolean isShiftPressed(@NonNull PointerKeyboardModifiers receiver)

true when the Shift key is pressed.

isSymPressed

public static final boolean isSymPressed(@NonNull PointerKeyboardModifiers receiver)

true when the Sym key is pressed.

isTertiaryPressed

public static final boolean isTertiaryPressed(@NonNull PointerButtons receiver)

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

positionChange

public static final @NonNull Offset positionChange(@NonNull PointerInputChange receiver)

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

positionChangeConsumed

public static final boolean positionChangeConsumed(@NonNull PointerInputChange receiver)

True if this PointerInputChange's movement has been consumed.

positionChangeIgnoreConsumed

public static final @NonNull Offset positionChangeIgnoreConsumed(@NonNull PointerInputChange receiver)

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

positionChanged

public static final boolean positionChanged(@NonNull PointerInputChange receiver)

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

positionChangedIgnoreConsumed

public static final boolean positionChangedIgnoreConsumed(@NonNull PointerInputChange receiver)

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