Click a UI Element (ui_element.click)
This function is available in versions after 20260507
Declaration
ok, info_or_err = ui_element.click(selector_or_element [, options ])
Parameters
- selector_or_element
Table. A selector, an element returned by a query, or a coordinate table
{ x = X, y = Y }. - options Optional, table. See Common options.
Returns
- ok
Boolean.
trueon success,nilon failure. - info_or_err Table on success, string failure reason on failure.
Description
Click a button, list item, keyboard key, or another clickable UI element. Coordinates in coordinate tables use physical pixels. For fixed-coordinate clicks, prefer touch.tap. If multiple targets match and no unique target can be chosen, this API may return
nil, "ambiguous target".
Example
local ui_element = require("ui_element")
local ok, info_or_err = ui_element.click({
title = "Continue",
role = "button",
})
if not ok then
sys.toast(info_or_err)
end
Note: Uses non-chapter API sys.toast.