How to set initial appearance of all buttons on UI using behaviors
Peter M. Brigham, MD
pmbrig at gmail.com
Mon Mar 5 21:29:28 CST 2012
Mar 5, 2012, at 6:51 PM, J. Landman Gay wrote:
> On 3/5/12 4:46 PM, Sivakatirswami wrote:
>> I have studied out behaviors a bit, but can we use a behavior button as
>> a kind of template for all the static props of other objects?
>> e.g. you have twenty buttons on a GUI and you want to change the look
>> and feel of them all at the same time.
>> I know you can set the script of buttons 1,2,3,4 using button A as a
>> behavior for each of them. but what about their default colors,
>> transparency shape button mode (round rectangle or regular or rectangle)
>> perhaps behaviors is not the way to go for this...
> You could do it with the "properties" property in conjunction with behaviors. Make your behavior button look exactly the way you want, and then loop through the other buttons and set their properties to the properties of the behavior button.
> One caveat: the rectangle and name will be changed too (since they're both properties,) which you probably don't want. So you should remove those entries from the array, along with any others you don't want to change, before actually setting anything. The dictionary explains it.
> The first time I did this I got disasterous results and had to revert the stack. Now I always look at the values in the debugger before I actually go ahead and set anything. It's easy to get all your buttons named the same and piled up on top of each other, but once it's properly edited and working, it's very fast and efficient.
I put together a little plugin that does just what Jacque suggests -- it uses the "properties" property to save and store properties of buttons, fields, and scrollbars so you can then apply them to new objects.
From the help text:
"The ObjectFormats plugin helps you apply stored properties to buttons, fields, or scrollbars in any stack. Set up a field, button, or scrollbar the way you want it and save its properties in this plugin, then apply the whole set of properties to future controls with a mouseclick. You can store a list of formats and use them repeatedly, eg, for consistency in GUI design, etc."
Properties that would be inadvisable to save and apply to new objects, such as the name, label, ID and altID, behavior, layer, text, icon, etc., are screened out automatically. The height and width (without the location) can be saved or not as part of the properties stored.
Try it out by downloading it at:
See if that helps you.
Peter M. Brigham
pmbrig at gmail.com
More information about the use-livecode