How to set the layer of draggable objects?

Rodney Somerstein rodneys at io.com
Sat Jul 6 19:54:01 EDT 2002


I have 12 groups of objects (each consisting of a rectangle with a 
label) on a card and need to set the layer of each one that I click 
on to be higher than all of the others. These groups are set up to be 
able to drag them around the card using the script from the Tip of 
the Week section of runrev.com with the addition of one statement to 
set the layer of the group.

local lMouseDown

on mouseDown
   set the layer of me to top
   put true into lMouseDown
end mouseDown

on mouseMove x,y
   if lMouseDown then set the loc of me to x,y
end mouseMove

on mouseUp
   put false into lMouseDown
end mouseUp

on mouseRelease
   mouseUp
end mouseRelease


The group does move to the top layer. However, sometimes the group 
doesn't seem to detect that I have let go of the mouse button and the 
movement of the object continues to track my mouse.

I thought that maybe I could simply put an if statement in the 
mouseDown handler and check to see if the group was currently the top 
one. The only way that I can think to do that is see if the layer of 
the group is less than the number of card parts. This doesn't seem to 
solve the issue of detecting the mouseUp.

Does anyone know a way around this?

Also, I would like to set the layer of the group to be higher than 
any other group, but no higher than the buttons, or possibly other 
objects later, that are on the card. How do I go about doing this? I 
can't simply set the layer to top to accomplish that as the layer of 
the rectangle will then be higher than any buttons as well. Any 
suggestions here would also be appreciated.

Thanks,

-Rodney



More information about the Use-livecode mailing list