Multiple background group hierarchy (was Goofy button behavior)

Ken Norris pixelbird at interisland.net
Tue Mar 11 00:03:00 EST 2003


**********
> Date: Mon, 10 Mar 2003 13:09:03 -0800
> Subject: Re: Goofy button behavior
> From: Richard Gaskin <ambassador at fourthworld.com>


> To avoid code redundancy, there must be a way to handle this at the stack
> level in one handler.
----------
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.
----------
> Do each of the 16 groups do completely different things in response to
> mouseUp, or is there any common behavior among them?
----------
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?
----------
> 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.

What I'm getting from your example is that the mouseUp catches the name of
the group to which the button belongs, then executes that set of statements,
rather like a shortcut through a bunch of nested if/then statements, as
opposed to operating on the group handlers. Is this correct?
---------- 
> If you prefer to keep the scripts specific to each group inside the group
> objects themselves, you could do something like this at the stack level:
> 
> on mouseUp
> send "DoMyFunkyGrooveThang" to the owner of the target
> end mouseUp
> 
> Life's too short to put that many small scripts in every button object. :)
----------
The Rev way of using the "send" command is a little different, too. I assume
the string in quotes is actually a handler name which will execute only
within the group the target belongs to, correct?

Thanks for the help,
Ken N.




More information about the use-livecode mailing list