image boundaries
Posted: Fri May 18, 2007 1:27 am
How would I set a boundary for an image on a stack, such that only the image can be moved within the boundary. Please help me. Thanks.
Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
Code: Select all
on mouseDown
grab me
end mouseDown
Let's say you have a rectangle graphic "tRect" that defines the boundaries,revmeup wrote:How would I set a boundary for an image on a stack, such that only the image can be moved within the boundary. Please help me. Thanks.
Code: Select all
local sRect
on mouseEnter
put the height of me / 2 into tH
put the width of me / 2 into tW
put the rect of grc "tRect" into sRect
add tW to item 1 of sRect
subtract tW from item 3 of sRect
add tH to item 2 of sRect
subtract tH from item 4 of sRect
end mouseEnter
on mouseMove
if the mouse is down then
if the mouseLoc is within sRect then set the loc of me to the mouseLoc
end if
end mouseMove