Skip to content

hoverElement

Moves the mouse pointer to the center of an element using trusted Electron pointer input, then polls until the element actually matches :hover.

Because the move is trusted, the real :hover state takes effect in the CSS engine — unlike dispatchEvent(new MouseEvent('mouseover')), which is untrusted and never sets :hover. It targets the single window’s global pointer, so only one element is hovered at a time.

Import:

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

Signature:

function hoverElement(params: HoverElementParams): Promise<void>

Parameters:

ParameterTypeDescription
paramsHoverElementParamsThe element to hover.

Returns: Promise<void> — A Promise that resolves once the element matches :hover.


Links to this page: