Relayering and dragging a group within a group

David Epstein dfepstein at comcast.net
Mon Jun 5 21:41:15 EDT 2006


Many thanks to Jonathan Lynch, whose post explains how to relayer  
groups inside a group.

> 1)set the relayergroupedcontrols property to true
> 2)move all the subgroups to the bottom of the master group - this  
> has to be
> done in the correct order, so that when this process is finished  
> the target
> group has moved up or down a layer as desired
> 3)set the relayergroupedcontrols property back to false

For those interested, a script follows for the case where we're  
moving one group to the top.  To keep the order of the non-relayering  
groups unchanged, I start from the "top" of the pile when moving them  
to the "bottom" of the pile; that explains the two repeat loops and  
the use of ids.

on mouseDown
   lock screen
   put the short id of the owner of the target into tgid
   put the layer of group "wb" into myL

   repeat with g = 1 to the number of groups in group "wb"
     get the short id of group g of group "wb"
     if it is not tgid then put it & space before hold
   end repeat

   set the relayerGroupedControls to true
   repeat for each word w in hold
     set the layer of group id w to 1+myL
   end repeat
   set the relayerGroupedControls to false
   unlock screen
   grab group id tgid

end mouseDown

My simpler approach (script below) can also do the relayering job.   
Its defect is that for some reason the "grab" command at the end is  
ignored, whereas in the Lynch-inspired script the "grab" command  
works as intended.  Does leaving "group editing mode" somehow  
terminate the mouseDown handler?


> on mouseDown
>   if "button" is in the target then
>
>     -- (1) put the group this button belongs to on top of other
>     -- groups that are subgroups of group "wb":
>     put the short id of the owner of the target into tgid
>     start editing group "wb"
>     set the layer of group id tgid to top
>     stop editing
>
>     -- (2) move this group with the mouse until the mouse is released:
>     grab group id tgid of group "wb" -- THIS DOESN'T WORK
>   end if
> end mouseDown
>

David Epstein




More information about the use-livecode mailing list