Page 1 of 1

Finding ParentScripts

Posted: Sat Apr 18, 2009 8:30 pm
by ronn
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

Posted: Mon Apr 20, 2009 4:31 am
by mwieder
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.

Posted: Mon Apr 20, 2009 3:40 pm
by ronn
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

Posted: Mon Apr 20, 2009 4:05 pm
by mwieder
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.