Returning coords with Clickable event. Usinsg them to position cursor when clicking in a textfield

This commit is contained in:
Dustin Swan 2026-02-04 18:58:27 -07:00
parent 787e071fbd
commit 9f078aaeef
No known key found for this signature in database
GPG key ID: 30D46587E2100467
5 changed files with 68 additions and 15 deletions

View file

@ -228,11 +228,15 @@ function measure(ui: UIValue): { width: number, height: number } {
}
}
export function hitTest(x: number, y: number): Value | null {
export function hitTest(x: number, y: number): { event: Value, relativeX: number, relativeY: number } | null {
for (const region of clickRegions) {
if (x >= region.x && x < region.x + region.width &&
y >= region.y && y < region.y + region.height) {
return region.event;
return {
event: region.event,
relativeX: x - region.x,
relativeY: y - region.y,
};
}
}
return null;