User`s guide

12 Code a Programmatic GUI
open on the second click. The callback can query the figure Sel ectionType
property to determine if it was a single or d ouble click.
List Box Examples. See the following examples for more information on
using list boxes:
“List Box Directo ry Reader (GUIDE)” on page 10-54 S h ows how to
creates a GUI that displays the contents of directories in a list box and
enables users to open a variety of file types by double-clicking the filename.
“Access Workspace Variables from a List Box (GUIDE)” on page 10-61
Shows how to access variables in the MA TLAB base workspace from
alistboxGUI.
Pop-Up Menu
When the pop-up menu Callback callback is triggered, the pop-up menu
Value property contains the index of the selected item, where 1 corresponds to
the first item on the menu. The
String property contains the menu items as
acellarrayofstrings.
Note A pop-up menu is sometimes referred to as a drop-down menu or combo
box.
Use Only the Index of the Selected Menu Item. This example retrieves
only the index of the item selected. It uses a switch statement to take action
based on the value. If t he contents of the pop-up m e nu are fixed, then yo u
can use this approach. Else, you can use the index to retrieve the actual
string for the selected item.
function popupm enu1 _Callback(hObject,event data)
val = get(hObject,'Value');
switch val
case 1 % User selected the first item
case 2 % User selected the second item
% Proceed with callback...
hObject
is the handle of the component for which the event was triggered.
12-24