Finding ParentScripts

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ronn
Posts: 26
Joined: Sun Apr 09, 2006 6:14 pm

Finding ParentScripts

Post by ronn » Sat Apr 18, 2009 8:30 pm

Trying to figure out the right way to set up parentScripts (behaviors). I believe the code must be set up in buttons but then "attaching" that script to other buttons presents a problem.

Using the Inspector, I can see a Behavior property for fields and for buttons like checkbox, push, radio, etc. But buttons like option, combo, popup don't show a Behavior property -- even though they seem to allow behaviors if set through script.

So is the problem that (1) the Behavior property is just missing from the inspector for those types of buttons, or (2) that by design I must use script to set those behaviors or (3) I'm not supposed to be using behaviors with option buttons.

And a related question -- at a later time, is there some way to determine which fields/buttons are attached to which behavior buttons?

Thanks.

... Ron

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Mon Apr 20, 2009 4:31 am

You *should* be able to set the behavior of any object, not just buttons of different types. It's a problem with the property inspector. As you've found out, you can set it by script without a problem.

The question of being able to query a button to see what other controls might be using it as a behavior has come up before on the lists, but as of now there's no way to do this. It will be quite useful if it does finally get implemented.

ronn
Posts: 26
Joined: Sun Apr 09, 2006 6:14 pm

Post by ronn » Mon Apr 20, 2009 3:40 pm

Thanks. I ended up calling this code from the message box to list the behaviors on the current card. Not too sure if it's all-inclusive or the best method but it seemed OK for my purposes.
... Ron

Code: Select all

on ListBehaviors
   put empty into bhvList
   repeat with x = 1 to the number of controls on this card
      if the behavior of control x is not empty then
         put the behavior of control x into tBhv
         put the name of control x & " = " & tBhv & " (" & the short name of  tBhv & ")" & cr after bhvList
      end if
   end repeat
   put bhvList
end ListBehaviors

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Mon Apr 20, 2009 4:05 pm

Yep - I think that's the way to do it. I thought you were looking for a way to examine a button and see if any controls were using it as a behavior object. Note also that groups can have their behaviors set as well, so to be all-inclusive you'll want to go through the groups as well as the controls.

Post Reply