Returning coords with Clickable event. Usinsg them to position cursor when clicking in a textfield
This commit is contained in:
parent
787e071fbd
commit
9f078aaeef
5 changed files with 68 additions and 15 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue