
2 Creating a GUI with GUIDE
2-22
index of the selected string. The pop-up menu callback reads the pop-up menu
Value property to determine what item is currently displayed and sets
handles.current_data accordingly.
1 Display the pop-up menu callback in the M-file editor. Right click the pop-up
menu component in the Layout Editor to display a context menu. From that
menu, select
View Callbacks -> Callback.
The GUI M-file opens in the editor if it is not already open, and the cursor
moves to the pop-menu callback which already contains this code:
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
2 Add the following code to the popupmenu1_Callback after the comment that
begins
% handles...
This code first retrieves two pop-up menu properties:
-
String – a cell array that contains the menu contents
-
Value – the index into the menu contents of the selected data set.
Commenti su questo manuale