Using Behaviours

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Using Behaviours

Post by phaworth » Tue Aug 18, 2009 5:22 pm

I'm setting up a library of reusable objects for my app by using custom behaviours but it seems that not all objects can have a custom behaviour. For example, I don't see a custom behaviour in the property inspector for an option menu button.

Is there a way around this for option menu buttons or any other objects that don't have a custom behaviour button in their property inspector?

Thanks,
Pete

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Tue Aug 18, 2009 5:38 pm

Like all rev uhm.. properties, the behaviour is a property.

so all you'd need to do is to set the "behaviour" property of your option button per script. See the relevant dictionary entry about the behaviour property for examples and more information on the correct usage.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Klaus
Posts: 14190
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Tue Aug 18, 2009 5:40 pm

Hi Pete,

you can assign a behaviour to ANY object, also if the IDE does not supply this button ;-)

Use the message box or a (temporary) button:
...
set the behavior of btn "your option button here" to the long ID of btn "the behvior button" of cd X of stack Y
...
In case you did not know:
There is only ONE object type "button".
An "option menu" button is just an ordinary button with its "style" property set to "menu" and its "menumode" property set to "option" :-)

Same applies to fields!
There is only ONE object type "field", all the variations come from the different properties.



Best

Klaus

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Tue Aug 18, 2009 5:55 pm

Thanks Klaus. Yes I did know that option menus are variations of buttons.

Glad to hear custom behaviours can be set on any object but wonder why the ability to do that was left out of the property inspector.

Pete

Post Reply