Skip to content

clickElement

Clicks the center of an element using trusted Electron pointer input.

The element-relative counterpart of clickMouse, mirroring the moveMouse / hoverElement split. Use clickMouse directly when the point to click is not the element’s center — the markdown editor’s margin, for instance, lies inside cm.scrollDOM but outside .cm-sizer, so no element’s center lands on it.

Must be awaited. Nothing here needs to wait, but the cross-platform twins do — on mobile the injection is a round-trip to the host, because the renderer cannot produce a trusted event itself — so the signature is the same on both platforms and a caller never rewrites its awaits when it grows a mobile lane.

Import:

import { clickElement } from 'obsidian-dev-utils/obsidian/desktop-trusted-input';

Signature:

function clickElement(params: ClickElementParams): Promise<void>

Parameters:

ParameterTypeDescription
paramsClickElementParamsThe element to click, the button to press and any modifiers to hold.

Returns: Promise<void> — A Promise that resolves once the click has been injected.


Links to this page: