Tab Panel Buttons and Selection

A Tab Panel Object has one or more panels associated with it. Usually each panel has a button associated with it.

This page explains how to set up the list of buttons (panels), and how Panorama keeps track of the currently selected panel.

#### Fixed Buttons

There are two modes for specifying the list of buttons — Comma Separated Values (a fixed list) and Formula (a dynamic list). The default is Comma Separated Values.

In Comma Separated Values mode you simply type in the list of button names into the Formula panel, separated by commas. You can also optionally have spaces between the names, as shown here.

To learn about when to use Formula mode, see Dynamic Buttons below.

#### Tab Panel Selection Variable

A Tab Panel normally has several panels, but only one is the current panel. In this example, the Text panel is currently selected.

Panorama uses a variable to keep track of which panel is currently selected. It’s up to you to specify the name of this variable, which you do via the Data option.

In this case, I have specified a variable named shapeChoice. Panorama will automatically create this as a fileglobal variable for me. You MUST set up a variable name here, you cannot leave this empty even if you don’t have any code that needs to know the current panel name. The tab panel itself uses this variable to keep track of which panel is selected, so it won’t work properly if you leave the Data option blank.

#### Accessing and Modifying the Selection Variable

If necessary, you can access or even modify the selection variable in a formula, program, or another graphics object. In this example, a Text Editor Object has been added to the form that displays the same shapeChoice variable that is linked to the tab panel object.

When a tab panel button is clicked, the Text Editor Object updates (look in the upper left hand corner to see the value change).

This works in reverse too! When the shapeChoice variable is edited, the panel changes.

A program can also change the selected panel. Just set the new value for the variable, then use the showvariables statement to update the display of the value.

#### Dynamic Buttons

There are two situations where you need to use Formula mode. One is if any of the button names contain commas. The other is if you want to modify the list of buttons on the fly. Here is an example of dynamic tab panel buttons. When the Extra Tabs checkbox is checked, four additional buttons appear.

Let’s see how this was set up. The first step is to add a checkbox object (see Data Button Object). This checkbox has been set up to link to a fileglobal variable named extraTabs. When the checkbox is clicked, the extraTabs variable will toggle between blank and a non-blank value (specifically, between blank and `x`).

The next step is to select the Tab Panel Object and change the Mode from Comma Separated Values to Formula.

The next step is to set up the formula associated with the Tab Panel Object. This formula must generate a carriage return separated list of button names.

The first part of the formula specifies the four basic buttons that are always displayed.

    commatocr("Boxes,Circles,Triangles,Stars")

The second part of the formula uses the ?( function to check to see if the extraTabs variable is blank or not. If it isn’t blank, four additional buttons are added to the list.

    ?(catcherror("",extraTabs)<>"",commatocr(",Text,Buttons,List,Matrix"),"")

(The catcherror( function is used in case the extraTabs variable doesn’t have a defined value, which can happen when the form is first opened.)

Everything is set up now, so clicking the checkbox will toggle the extra tabs on and off.

#### Diagnosing Formula Problems

If your formula has a problem it can be a bit tricky to figure out what’s wrong since you can’t directly see the text produced by the formula. In that situation you can use the Object Value dialog to display the entire formula result. See Diagnosing a Formula embedded in a Form Object to learn how to use this dialog.

See Also

- Tab Panel Appearance -- appearance options for a Tab Panel Object.
- Tab Panel Constructor -- quickly creating a Tab Panel Object from a template.
- Tab Panel Content -- setting up the content for a Tab Panel Object.
- Tab Panel Forms -- setting up the forms for a Tab Panel Object.
- Tab Panel Object -- switchable tab panels.

History

Version | Status | Notes
10.0 | New | New in this version.