Problems placed grouped groups

Ken Ray kray at sonsothunder.com
Tue Mar 15 12:49:37 EST 2005


>> Those would bypass the objects in the embedded group and the embedded group
>> itself. Messages sent to the parent group (what I called the "main group")
>> would be:
>> 
>>   (message) -> main group -> card
>> 
>> Ken Ray
> 
> Ken, aren't you thinking of normal groups? Isn't it normally the
> other way around that background (bg group) gets messages after the
> card? Wouldn't it follow that in both cases the sub-background should
> get them all? But then should it get them also when message was sent
> to another background?

Good question. So I tested this and here's what I discovered...

I make a standard button called "Round", grouped it into a group called
"Embedded", then created another button (a square one) called "Square", and
then grouped the "Embedded" group along with the "Square" button and called
it "Main". I then placed another button called "Outsider" just sitting on
the card, not inside a group. I then inserted mouseUp scripts in all the
objects to identify themselves and pass the message along. So the structure
is like this:

Stack
  Card
    Button "Outsider"
    Group "Main"
      Button "Square"
      Group "Embedded"
        Button "Round"
  
OK. Here's how it goes with backgroundBehavior of both groups turned OFF,
clicking on each of the buttons:

   Round -> Embedded -> Main -> Card -> Stack
   Square -> Main -> Card -> Stack
   Outsider -> Card -> Stack

I then turned on backgroundBehavior for group "Main", but left it off for
group "Embedded". Here's the results (* = backgroundBehavior is ON):

   Round -> Embedded -> Main* -> Card -> Stack
   Square -> Main* -> Card -> Stack
   Outsider -> Card -> Main* -> Stack

I then turned it OFF for "Main", and ON for "Embedded":

   Round -> Embedded* -> Main -> Card -> Stack
   Square -> Main -> Card -> Stack
   Outsider -> Card -> Stack

Finally, I turned it ON for both groups:

   Round -> Embedded* -> Main* -> Card -> Stack
   Square -> Main* -> Card -> Stack
   Outsider -> Card -> Main* -> Stack

>From this, it seems we have the following rules:

1) If a "background" group is contained inside of a group that is *not* a
background, its backgroundBehavior is ignored for the purposes of message
passing.

2) A background group will only receive a message once, regardless of
whether its backgroundbehavior is ON or not. So we have this:

  Round -> Embedded -> Main* -> Card -> Stack

and NOT this:

  Round -> Embedded -> Main* -> Card -> Main* -> Stack

3) A corrolary to #2: Background behavior only counts for objects that are
not *inside* the background group; in my example it only affected the
Outsider button and the Card itself (if I clicked on the Card with the Main
group as background, I got "Card -> Main* -> Stack").


I don't know about you, but I've learned a lot about background behavior
today...

:-)

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list