What it does
context_utils
UI context helpers for desktop-like UI flows — parse a pipe-delimited context-menu payload string, and detect whether a click counts as a double-click on the same shortcut. Stateless, no engine calls. Safe to call from any context.
Exports
M.parseContextPayload(raw: string?) -> ContextPayload— parse"x|y"or"id|x|y"into{ id, x, y }. Defaultsx/yto120.M.shouldOpenOnClick(shortcutId, prevId, now, prevClick, threshold?) -> boolean— true when the click is a double-click on the same shortcut withinthresholdseconds (default0.40).
Types:
ContextPayload = { id?: string, x: number, y: number }
Usage
local ContextUtils = require("@builtin::modules.engine.ui.context_utils")
local ctx = ContextUtils.parseContextPayload("shortcutA|120|240")
local dbl = ContextUtils.shouldOpenOnClick("A", "A", now, lastAt)
Notes
- A 2-token payload is treated as bare coordinates (
"x|y"); a 3-or-more-token payload is treated as"id|x|y". - Coordinates fall back to 120 if any token fails
tonumber. - Non-string inputs return the all-defaults payload (
{ x = 120, y = 120 }).
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.