fixing hitTest bounds for clickable. using Constructors for Clickable events. starting to think about design systems..
This commit is contained in:
parent
5af3af6b6c
commit
86996ed4ef
8 changed files with 67 additions and 26 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue