Skip to main content

Long Press by Coordinates

The Long Press by Coordinates action performs a long press at the specified screen coordinates. It is commonly used to open context menus, enter selection mode, or display additional options.

When to Use​

Use this action when you want to:

  • Open a context menu.
  • Select application icons.
  • Enter edit mode.
  • Perform drag-and-drop preparation.

Syntax​

var task = suremdmjs.automate().longPressCoordinates(
<X Coordinate>,
<Y Coordinate>
);

suremdmjs.automate().performAction(
task,
"onSuccess",
"onFailure"
);

Parameters​

ParameterRequiredDescription
X CoordinateYesHorizontal screen coordinate in pixels.
Y CoordinateYesVertical screen coordinate in pixels.

Example​

!#suremdmjs

selectIcon();

function selectIcon() {
var task = suremdmjs.automate().longPressCoordinates(
350,
750
);

suremdmjs.automate().performAction(
task,
"selectionOpened",
"selectionFailed"
);
}

function selectionOpened() {
suremdmjs.log("Long press completed.");
}

function selectionFailed() {
suremdmjs.log("Unable to perform long press.");
}

Expected Result​

The specified screen location receives a long press, and the associated context menu or selection mode is displayed.

💬 Help us improve this documentation

Was this information useful?

Your feedback helps us keep our documentation accurate, up to date, and useful.