Radio buttons work well when there are only a few options. When you get past a dozen or so options, you’ll probably want to use a pop-up menu or Text List Object instead.

Creating a Basic Popup Menu

Start by dragging a pop-up menu object from the Object Library to the form. Then enter the name of of the field or variable that will be linked to the pop-up menu. Finally, switch to the Formula panel and enter the menu choices, separated by commas (you can optionally include spaces, as shown below). To save time, I preloaded the menu choices into the clipboard.

For a basic pop-up menu, that’s it … you’re done!

Separator Lines

If you want separator lines in the menu, just use (- in any spot where you want a separator line.

Dynamic Popup Menus

The examples shown so far have been fixed menus – menus that never change. If you need a pop-up menu that can change dynamically, switch the object to Formula mode.

In this mode, the Formula panel actually contains a formula, instead of a comma separated list. Here is the revised formula for our National Park example. Notice that now each national park is on a separate line, and also note the quote characters at the beginning and end, which are necessary to make this a valid formula.

One minor advantage of this mode is that it allows menu choices to contain commas, which isn’t allowed in the Comma Separated Values mode. But the real power of Formula mode is unleashed when you use a variable or field in the formula. Since the variable or field may be changed at any time with a procedure (or even with standard data entry), the pop-up menu can change at any time. For example, suppose you want to make the national park menu user editable. I can create a Text Editor Object linked to a variable named NationalParkNames, like this:

Then I can change the pop-up menu formula to this same variable name.

Now the pop-up menu name can be edited on-the-fly.

In this example, the formula is very simple, just a single variable, but you can use as complex of a formula as you need.

Custom Formulas

If you want to go the full Monty, you can create a fully custom menu with the menu( and menuitem( functions (see Custom Menus. With these, you have full control over the menu, including styles, colors, images, icons, checkmarks, submenus, etc, like this:

Here is the formula for this menu.

To learn how to design complex menus with these functions, see Custom Menus.

Popup Menu Options

Click on the magic panel to see and modify the pop-up menu options:

Data – This is the field or variable that is linked to the pop-up menu. You can either type in the name of a field or variable, or you can choose a field name from the pop-up menu (on the right). Panorama will also auto-complete field names as you type.

When you select a choice from a pop-up menu, that choice will be be placed into the linked field or variable. Of course the value of a field or variable can also be set other ways, for example with an assignment statement in a procedure. This code will work with the pop-up menu shown in earlier examples to change the displayed national park to Grand Canyon.

parkName = "Grand Canyon"
showvariables parkName

There is a problem, however, if the new value is not one of the available choices in menu.

parkName = "Petite Canyon"
showvariables parkName

If the value is not a menu choice, the value will not be displayed. Instead, the pop-up menu will be blank.

The reason the pop-up menu is blank is that Panorama uses standard Apple pop-up menu code, and Apple’s code will only display values that are included in the menu. See Cocoa Objects for more information about why Panorama uses standard Apple code, in spite of some restrictions like this.

Note: If you specify a variable that has not already been created with a procedure, Panorama will automatically create a global, fileglobal or windowglobal variable with this name the first time the form is displayed. The type of variable created depends on the Form Preferences.

Size – Popup menu buttons may be one of three fixed heights: Regular, Small and Mini.

These are the only sizes available – see Cocoa Objects for more detail about the reasons for this limitation.

System Font – If this option is checked the popup menu will always be displayed using the standard system font and font size. Uncheck this option if you want to use a non-standard font or size (in which case you select the font and size from the Text panel, see Fonts).

Transparent – If this option is checked the button will be completely transparent (the title will also be hidden). This is handy if you want to put the button on top of other graphics, however, see Using Any Type of Object as a Pop-up Menu below for an alternate method for doing this.

Disabled – This option disables the button. When the button is disabled it is dimmed and it can’t be clicked on.

Of course there is no point in a button that is permanently disabled. So normally you would enable/disable a button with a procedure. See {Push Button Objects for an explanation of how a procedure can enable/disable a button.

Using Any Type of Object as a Pop-up Menu

Using the popupclick statement and a few lines of code, Panorama X allows any type of object can be converted into a pop-up menu. In this example, the button was created with the Font Awesome Icons wizard.

When the icon is clicked on, it runs the code which pops up the menu.

In older versions of Panorama (6 and earlier), a custom pop-up menu like this would have to be created by layering two objects on top of each other – an image and a transparent button. Now only a single object is needed.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0 from Popup Menu SuperObjects, but with some new features. This version of Panorama only supports standard system button styles, so some button styles that were available in previous versions of Panorama are no longer available.