Goofy button behavior

Richard Gaskin ambassador at
Mon Mar 10 16:12:09 EST 2003

Ken Norris wrote:

> **********
>> Date: Mon, 10 Mar 2003 10:38:11 +0000
>> From: Dave Cragg <dcragg at>
>> Subject: Re: Goofy button behavior
>> But when you set the backgroundbehavior, the group's script is also
>> the background script.
> ----------
> Are you sure? I don't see that a background is the same as a group. I
> thought there is a difference, i.e., there can be more than one group with
> bg behavior. Does this mean all groups with bg behavior excute each other's
> scripts?
> ----------
>> I don't think it's wonky that a background
>> script should catch unhandled messages from controls on the card.
> ----------
> No, but that there may be more than one group with background behavior.
> OK, I have 47 buttons in a group with bg behavior. The intention is to have
> its mouseUp handler work for ONLY the objects assigned to that group. IOW,
> the background behavior is intended for group(s) to show up on all the
> cards. Since there is really no such thing as a "background script", I
> expect the separate groups to act like controls, i.e., retain independent
> scripts operable only by the objects which belong to each. There are also 2
> large images (800x600) which are in 2 separate groups, also with bg behavior
> (no scripts). 
> So if I have 16 separate groups with bg behavior and different mouseUp
> handlers in each group, any non-grouped button with an empty script will
> execute all 16 different handlers? This is a difficult concept for me.
> That might be useful in some cases, but what it looks like is that I should
> go ahead and put a mouseUp handler in each of the 47 buttons of the group
> which all call a group handler (seems redundant). Or maybe I should put the
> other buttons, which each have different handlers, in their own bg group
> with no script. Would they still try to run the scripts of other bg groups
> if the script of the group to which they belong is empty? What if a button
> belonging to another group WITH bg behavior has no script. What will it do
> with regard to mouseUp handlers which are in other bg groups?
> I just can't seem to get my brain wrapped around how groups with bg behavior
> work. It seems that there is no hierarchy between groups which all have
> background behavior, since there is not really a background entity with a
> script. I really need a 3D map, some kind of visual representation of how it
> works, cuz I'm still not gettin' it.

To avoid code redundancy, there must be a way to handle this at the stack
level in one handler.

Do each of the 16 groups do completely different things in response to
mouseUp, or is there any common behavior among them?

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"
  case "GroupName2"
  end switch   
 end mouseUp

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. :)

 Richard Gaskin 
 Fourth World Media Corporation
 Developer of WebMerge 2.2: Publish any database on any site
 Ambassador at
 Tel: 323-225-3717                       AIM: FourthWorldInc

More information about the use-livecode mailing list