about backgroundbehaviour and message passing
rodneytamblyn at paradise.net.nz
Sun Sep 7 02:48:00 CDT 2003
Setting the backgroundbehaviour of a group to true causes it to be
added to the message passing hierarchy after the card. As a result it
receives all the card events such as opencard, preopencard, closecard
etc. The events opengroup and closegroup (as well as openbackground &
closebackground which are included for Hypercard compatability) are
only sent to groups who backgroundbehaviour is set to true. I think
that opengroup and closegoup should be sent to all groups.
In the situation where you want groups that only respond to events
generated by controls that are amongst it's children, you must manually
send events such as opencard, opengroup etc if you need them.
Therefore I've found it best to set backgroundbehaviour to false, and
have a handlers (at stack or library level) which respond to opencard,
closecard, preopencard etc, gets the groups of the card, and sends it
the desired event.
To ensure groups receive initiator messages (such as opencard,
preopencard) while still preventing them from receiving events
originated by objects which are not their children do the following:
Place a handler on preclosecard which inspects the groups on the card
and determines which should receive events (eg by checking name or a
custom property). For those that need to receive events, set the
backgroundbehaviour to true. Now the opencard message will propagate
up through the card, through the groups (which now have
backgroundbehaviour enabled), and when it reaches the stack level, the
reverse handler will set the backgroundbehaviour to false - ensuring
the group only receives events generated by it's children and not other
objects on the card.
In stack script, all groups have now received opencard, check which
shouldn't have backgroundbehaviour
In stack script:
groups won't receive this, so send it to them
#use whatever mechanism you need to work out which grps need this done
repeat for each line x in the customPropertySets of the target #ie
if there is a group x then set the backgroundbehaviour of group x
#could also send them a preclose msg here, probably best not to send
them preclosecard, use grppreclose or #something else
set the backgroundbehaviour of me to false #removes grp from message
One side effect is that when you create new cards the groups will be
placed on them, which may well be what you want anyway - but you need
to bear this in mind.
Your comments on the above solution & whether there is a better way to
achieve what I want would be of interest.
44 Melville Street
+64 3 4778606
More information about the use-livecode