How is the built-in controls made?

J. Landman Gay jacque at hyperactivesw.com
Wed Nov 9 17:40:41 EST 2005


Jan Sælid wrote:
> So...
> 
> If I understand this right the "Tab Panel" is just a button. And the 
> face of the button is what changes.
> Ok.
> But...The "face"? What is the face made of? Polygons? Lines?
> 
> The reason I'm making a fuzz about this is that I would really like to 
> make a button
> that behaves like that, instead of making 2 to 10 buttons in a group. It 
> saves space if you can make a button behave like that.
> And I think it is much cleaner to have 1 object instead of a lot in a 
> group. (just for references)
> I don't like to use groups all the time, because I don't want to have to 
> many objects in my stack.

A tab button is just another style of menu button. Instead of popping 
down like a regular menu button, all the contents are displayed at once, 
each one in a separate tab. Other than appearance, you work with tab 
buttons just as you do menus. The text (that is, the content) of the 
button becomes the items listed in the tabs. When a user chooses a tab, 
a "menupick" message is sent. In the case of tab buttons, the menupick 
message contains two parameters instead of the usual one: the name of 
the tab the user clicked on, and the name of the tab that was previously 
selected.

To make a tab button functional, you script behaviors that use either 
groups or cards. The simplest way is to use cards. When a tab is 
clicked, you go to the card corresponding to that menu choice. (In this 
case, make sure your tab button is in a background group that has been 
placed on each card.) Alternately, you can hide and show groups which 
correspond to the choice. This method keeps everything on a single card. 
In this case, the second parameter is helpful because it tells you which 
of the previously displayed contents you need to hide.

You are right that using a tab button is better than making your own tab 
panel. Not only is the hiliting and selection behavior taken care of for 
you, but the button will be drawn with the correct appearance for the 
current operating system.

In the scripting conference stack "Backgrounds and groups" there is an 
example of using a tab button. There is another example in the 
"Controls" scripting conference stack. Both are located here:

<http://support.runrev.com/scriptingconferences>
-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list