next up previous contents
Next: Sliders Up: Commonly Used Code Previous: Check Boxes   Contents

Drop-down Menus

In the following, the menu object needs to first be identified using:

contents = get(hObject,'String');
Subsequently, the menu entry needs to be checked for extraction and setting of information.

if (strcmp(contents{get(hObject,'Value')},'MenuEntry1')),

   set(handles.data, 'String', 'Data1');

elseif (strcmp(contents{get(hObject,'Value')},'MenuEntry2')),

   set(handles.data, 'String', 'Data2');

else

   msgbox('Error with menu callback. Parameter passed is not recognised.');

end

This should record the menu selection appropriately.



2004-05-19