Multiple background group hierarchy (was Goofy button behavior)

Ken Ray kray at sonsothunder.com
Tue Mar 11 00:39:01 EST 2003


> I agree, but my lack of conceptual understanding is causing 
> some enmity between scripts. Backgrounds and groups seem 
> incongrous to me, i.e., I can understand backgrounds because 
> of HC, and I can understand groups in Rev, but when I mix 
> them together, stuff tends to blow up.

You're not the first one. ;-)

Seriously, if you don't think of background behavior relative to the way
things worked in HC, but think of them as "shared groups" vs. "unshared
groups" it makes the conceptual map click a bit better. Actually, the
backgroundBehavior is *separate* from whether a group is shared among
cards... its just that Rev turns the backgroundBehavior ON when it
places a shared group on a new card (I believe).

> This is semi-hypothetical. I actually have 4 background 
> groups at this time, but it's certainly conceivable that I 
> might have 16. The question is, how do I get various groups 
> of buttons to do the same general things in each group with 
> each group different, and still have all of them available on 
> all cards, i.e., background behavior?

Well, technically you can share a group among cards in a stack, but
leave the backgroundBehavior off. What this does is cause the objects
inside the group to pass messages to the group as its parent, but other
objects on the card(s) won't pass their messages to that group because
it does not have "background behavior".

> ----------
> > I'm picturing something like this, in the stack script:
> > 
> > on mouseUp
> > switch the short name of the owner of the target -- the group name 
> > case "GroupName1" DoSomething
> > break
> > case "GroupName2"
> > DoSomethingElse
> > break
> > end switch   
> > end mouseUp
> ----------
> You may be onto something. The switch/case concept is new to 
> me, I'll have to play around with it to see how it works, but 
> what I'm really interested in is the "owner of the target" 
> thing. I haven't gotten into that much, except windows in HC, 
> before now.

If you MUST keep the backgroundBehavior on, I generally use the magic
phrase "if the owner of the target is me then" to indicate only objects
that it owns, and not any other objects. So for example if you had a
group whose backgroundbehavior is on, and had code that said:

on mouseUp
  if the owner of the target is me then
    -- take action
  else
    pass mouseUp
  end if
end mouseUp

This would cause clicks on objects *outside* the group to go to the
group, but since those objects are not "owned" by the group, it falls to
the "else" clause and passes the mouseUp up the hierarchy.

Hope this helps,

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




More information about the use-livecode mailing list