on deleteGroup
Devin Asay
devin_asay at byu.edu
Mon Jan 4 16:40:41 EST 2010
On Jan 1, 2010, at 12:45 PM, David Bovill wrote:
> Just noticed that the deleteGroup message is not sent when the group
> is
> nested - anyone got an idea how to get around this?
>
> Say you have a group that you want to do some tidying up if a user
> deletes
> it - and so you put a handler like this in the group itself:
>
> on deleteGroup
>> beep
>> doSomeTidying
>> pass deleteGroup
>> end deleteGroup
>>
>
> Which works fine if it is a toplevel group - but when this group is
> inside
> another group deleting the toplevel group triggers a deleteGroup
> message
> which travels up the hierarchy to the card - but no deleteGroup
> messages are
> sent from the inner groups - this means you can't attach appropriate
> behaviors to the groups.
>
> Wandering if anyone has looked at this - I can't think how to do it as
> deleteGroup is sent after deletion so even a frontscript would not
> be able
> to tell what was inside a deleted group. Even the new closeControl
> message
> does not seem to be sent in these circumstances?
David,
Maybe you'll need to check the child objects of the group before you
delete the parent group. If they have child groups delete them first
from the "inside out", so that each group is deleted individually and
so triggers the deleteGroup message.
repeat with x= 1 to the number of groups in group "parent"
if there is a group x of group "parent" then
delete group x of group "parent"
else
exit repeat
end if
end repeat
Regards,
Devin
Devin Asay
Humanities Technology and Research Support Center
Brigham Young University
More information about the use-livecode
mailing list