Group Conundrum Take 2 (Ignore first post)
Ken Ray
kray at sonsothunder.com
Thu Sep 18 13:30:49 EDT 2008
> Pretty simple. I was focussed on setting layer numbers. This is much
> easier-- and the trick is to work inside the edit group command. Also Ken
> Ray's function is important as well-- as you can't get a unique long owner
> for a control which is part of a group.
>
> function stsLongOwnerID pObjID,pOpt_NumLevels
> if pOpt_NumLevels = "" then put 1 into tNum
> else put pOpt_NumLevels into tNum
> if word ((4*tNum)+1) of pObjID is among the items of "group,card" then
> delete word 1 to (4*tNum) of pObjID
> end if
> return pObjID
> end stsLongOwnerID
Actually, I've been developing an app that needed to relayer groups within
other groups. Here's the code I've been using that doesn't require "edit
group" ... see if it works for you (watch word wraps):
-- Note: You may want to substitute stsLongOwnerID below if necessary
on BringToFront pObjectRef,pStackName
--|
--| Brings a control to the front of its owner, but does not relayer it
--| outside its owner
--| (based on 'bringToFrontWIthinOwner' by Dick Kriesel)
--|
if exists(pObjectRef) then
put the relayerGroupedControls into tOldRelayer
put the lockScreen into tOldLockScreen
put long id of pObjectRef into tTarget
put long owner of pObjectRef into tOwner
if word 1 of tOwner <> "card" then put (the layer of tOwner + 1) into
pObjectLayer
else put 1 into pObjectLayer
repeat with x = (the number of controls of this card of stack
pStackName) down to 1
put (the long id of control x of of this card of stack pStackName)
into tID
if (the long owner of tID is tOwner) and (tID is not tTarget) then
put (tID & cr) after tPeers
end if
end repeat
delete char -1 of tPeers
if tOldLockScreen is "false" then lock screen
set the relayerGroupedControls to true
repeat for each line tPeer in tPeers
set the layer of tPeer to pObjectLayer
end repeat
if tOldLockScreen is "false" then unlock screen
set the relayerGroupedControls to tOldRelayer
else
return "Error: Object at '" & pObjectRef & "' does not exist."
end if
end BringToFront
on BringForward pObjectRef,pStackName
if exists(pObjectRef) then
put the relayerGroupedControls into tOldRelayer
put the lockScreen into tOldLockScreen
put long id of pObjectRef into tTarget
put long owner of pObjectRef into tOwner
if word 1 of tOwner <> "card" then put (the layer of tOwner + 1) into
pObjectLayer
else put 1 into pObjectLayer
repeat with x = 1 to (the number of controls of this card of stack
pStackName)
put (the long id of control x of of this card of stack pStackName)
into tID
if (the long owner of tID is tOwner) then put (tID & cr) after tPeers
end repeat
delete char -1 of tPeers
put "" into tNewPeers
put lineOffset(tTarget,tPeers) into tMatchLine
if tMatchLine <> the number of lines of tPeers then
repeat with x = (tMatchline+1) down to 1
if x = tMatchLine then next repeat
put line x of tPeers & cr after tNewPeers
end repeat
delete char -1 of tNewPeers
if tOldLockScreen is "false" then lock screen
set the relayerGroupedControls to true
repeat for each line tPeer in tNewPeers
set the layer of tPeer to pObjectLayer
end repeat
if tOldLockScreen is "false" then unlock screen
set the relayerGroupedControls to tOldRelayer
end if
else
return "Error: Object at '" & pObjectRef & "' does not exist."
end if
end BringForward
on SendBackward pObjectRef,pStackName
if exists(pObjectRef) then
put long id of pObjectRef into tTarget
put long owner of pObjectRef into tOwner
put "" into tPeer
repeat with x = 1 to (the number of controls of this card of stack
pStackName)
put (the long id of control x of of this card of stack pStackName)
into tID
if (the long owner of tID is tOwner) then
if tID <> tTarget then put (tID & cr) after tPeers
else put line -1 of tPeers into tPeer
end if
end repeat
if tPeer <> "" then
BringForward tPeer
end if
else
return "Error: Object at '" & pObjectRef & "' does not exist."
end if
end SendBackward
on SendToBack pObjectRef,pStackName
if exists(pObjectRef) then
put the relayerGroupedControls into tOldRelayer
put the lockScreen into tOldLockScreen
put long owner of pObjectRef into tOwner
repeat with x = 1 to (the number of controls of this card of stack
pStackName)
put (the long id of control x of of this card of stack pStackName)
into tID
if (the long owner of tID is tOwner) then
put tID into tPeer
exit repeat
end if
end repeat
if tOldLockScreen is "false" then lock screen
set the relayerGroupedControls to true
set the layer of pObjectRef to the layer of tPeer
if tOldLockScreen is "false" then unlock screen
set the relayerGroupedControls to tOldRelayer
else
return "Error: Object at '" & pObjectRef & "' does not exist."
end if
end SendToBack
Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list