Groups and backgrounds

Ken Ray kray at
Thu Jul 8 11:52:19 CDT 2004

> First, are a background group's scripts available in a preOpenCard  
> message if the background exists on the card that is being entered?


Once again I verified with a simple test: make a stack with two cards, the
first card has nothing on it and the second has a group with
backgroundbehavior=true a script that traps preopencard that brings up an
answer dialog. Go to card 1, then back to card 2 -> dialog appears.

> And second - that means that the message path is -
> frontscripts->object->group->card->stacks->libraryStacks->backscripts
> when there are no backgrounds. And,
> frontscripts->object->group->card->backgrounds->stacks->libraryStacks-
>  >backscripts
> if there is a background.
> But what is the message path for objects within the 
> backgrounded group?

OK, you sort of have it right. For ease of description, I'm going to refer
to groups with background behavior turned on as "shared groups" (or you can
substitute "backgrounds" if you like, but I'm trying to be unambiguous.)
Here's how it works:

Messages follow this chain:

  frontscripts ->
     card object -> 
        unshared group (if applicable) ->
           card ->
              shared group (background) (if applicable) ->
                 substack (if applicable) ->
                    mainstack ->
                       libraryStacks ->

Objects that are inside of a shared group have a slightly different message
path than those that are outside of the group. Once again let's use my
simple example of a single card with a shared group of buttons and one
button outside the group. Inside the button scripts (both those inside the
group and those outside), the handler simply calls "Test". The shared group
has this handler:

on Test
  answer "SHARED GROUP"
  pass Test
end Test

The card script has a handler:

on Test
  answer "CARD"
  pass Test
end Test

And the stack has a handler:

on Test
  answer "STACK"
end Test

When you click on the button *outside* the shared group, you get:


But when you click on a button *inside* the shared group, you get:


Here's the reason: For the button *outside* the shared group, the shared
group looks and acts like a background, i.e. the message goes from the
button to its owner (the card) and then to any and all shared groups before
going to the card's owner (the stack). 

For the button *inside* the shared group, the group look and acts just like
a regular group *even though the backgroundbehavior is on*, so it goes from
the button to its owner (the group) to the group's owner (the card) before
going to the card's owner (the stack). 

Now if you had a second shared group on the card, the second shared group
would be treated like a background for *both* of the buttons (the one
outside all shared groups and the one inside shared group #1), so the
message path would be:

For the button *outside* all shared groups:


For the button *inside* shared group #1:


I hope this is clear as mud...


Ken Ray
Sons of Thunder Software
Email: kray at
Web Site:

More information about the use-livecode mailing list