longClick

Function

Common
fun MouseInjectionScope.longClick(
    position: Offset = center,
    button: MouseButton = MouseButton.Primary,
)

Use button to long-click on position, or on the current mouse position if position is unspecified. The position is in the node's local coordinate system, where (0, 0) is the top left corner of the node. The default button is the primary button.

Parameters

positionThe position where to click, in the node's local coordinate system. If omitted, the center of the node will be used. If unspecified, clicks on the current mouse position.
buttonThe button to click with. Uses the primary by default.
Common

Deprecated Replaced by TouchInjectionScope. Use performTouchInput instead of performGesture

fun GestureScope.longClick(
    position: Offset = center,
    durationMillis: Long = LongPressTimeoutMillis + 100,
) = delegateScope.touch { longClick(position, durationMillis) }

Performs a long click gesture at the given position on the associated node, or in the center if the position is omitted. By default, the durationMillis of the press is LongPressTimeoutMillis + 100 milliseconds. The position is in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Parameters

positionThe position of the long click, in the node's local coordinate system. If omitted, the center position will be used.
durationMillisThe time between the down and the up event
Common
fun TouchInjectionScope.longClick(
    position: Offset = center,
    durationMillis: Long = viewConfiguration.longPressTimeoutMillis + 100,
)

Performs a long click gesture (aka a long press) on the associated node.

The long click is done at the given position, or in the center if the position is omitted. By default, the durationMillis of the press is 100ms longer than the minimum required duration for a long press. The position is in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Parameters

positionThe position of the long click, in the node's local coordinate system. If omitted, the center of the node will be used.
durationMillisThe time between the down and the up event