bringToFrontWithinOwner (was: relayering groups within groups)
Dick Kriesel
dick.kriesel at mail.com
Fri Feb 3 04:16:15 EST 2006
Here's a handler that brings a control as close to the front as possible
without affecting its owner.
No control has its owner changed. All controls other than the one that
moves keep their original sequence within their owners. No controls are
copied or deleted, so no system messages like newGroup and deleteGroup get
sent. There's no "start editing" command, so stepping through the handler
doesn't cause unexpected results (see the dictionary entry for "start
editing"). The previous value of the relayerGroupedControls is restored at
the end.
The optional input parameter identifies the control to bring to the front.
With no input the handler operates on the target.
on bringToFrontWithinOwner pControl
if pControl is empty then
put abbr id of the target into tTarget
else
put abbr id of pControl into tTarget
end if
put long owner of tTarget into tOwner
if word 1 of tOwner is "card" then
put 1 into tLayer
else
put the layer of tOwner + 1 into tLayer
end if
repeat with i = number of controls down to 1
if long owner of control i is tOwner then
if abbr id of control i is not tTarget then
put abbr id of control i & cr after tPeers
-- note: peers share the same owner
end if
end if
end repeat
lock screen
put the relayerGroupedControls into tRelayerGroupedControls
set the relayerGroupedControls to "true"
repeat for each line tPeer in tPeers
set the layer of tPeer to tLayer
end repeat
set the relayerGroupedControls to tRelayerGroupedControls
unlock screen
end bringToFrontWithinOwner
The handler passed my tests. If you find a problem with it, please let me
know.
-- Dick
More information about the use-livecode
mailing list