fixing hitTest bounds for clickable. using Constructors for Clickable events. starting to think about design systems..

This commit is contained in:
Dustin Swan 2026-02-03 13:00:54 -07:00
parent 5af3af6b6c
commit 86996ed4ef
No known key found for this signature in database
GPG key ID: 30D46587E2100467
8 changed files with 67 additions and 26 deletions

View file

@ -5,7 +5,7 @@ type ClickRegion = {
y: number;
width: number;
height: number;
event: string;
event: Value;
};
type TextInputRegion = {
@ -171,14 +171,12 @@ function measure(ui: UIValue): { width: number, height: number } {
case 'text-input':
return { width: ui.w, height: ui.h };
}
// return { width: 0, height: 0 };
}
export function hitTest(x: number, y: number): string | null {
export function hitTest(x: number, y: number): Value | null {
for (const region of clickRegions) {
if (x >= region.x && x < region.x + region.width &&
x >= region.y && y < region.y + region.height) {
y >= region.y && y < region.y + region.height) {
return region.event;
}
}