Constraining the pointer within a rect
Jan Sælid
janselid at broadpark.no
Fri Aug 18 05:06:10 EDT 2006
Hi David, I sent you another suggestion. Maybe it slipped through. Try it.
It's stable. Just put this into the script of a button or rectangle. Try it
---
local constrain,boxL,boxR,boxT,boxB
ON mouseDown
put item 1 of rect of me+4 into boxL -- change 4 to your own needs
put item 3 of rect of me-4 into boxR -- change 4
put item 2 of rect of me+4 into boxT -- change 4
put item 4 of rect of me-4 into boxB -- change 4
put true into constrain
END mouseDown
ON mouseMove x,y
IF not constrain THEN exit mouseMove
set the screenmouseloc to \
globalloc(min(boxR,max(boxL,(x))) & "," &min(boxB,max(boxT,(y))))
END mouseMove
ON mouseUp
put false into constrain
END mouseUp
ON mouseRelease
mouseUp
END mouseRelease
---
Jan
More information about the use-livecode
mailing list