MATLAB: Interactive GUI: pup-up menus, list

guiinteractivelistboxpopup menurefresh

Hi,
I am making a small interface where the objects interact with each other. Specifically: I have 2 popup menus and a list, and some buttons. – I populate the popup menus at the beginning. When user selects one item in one of the menus, the other changes the items accordingly (only items relevant to the selected) and vice versa. – When user pushes button "Select", the data from popup menus are added to the list. – When user selects an item in the list and clicks on button "remove", the item will be removed.
I can read the data and stuff them into handles, even into the menus and the listbox, but I don't know how to re-generate the menus/list. When I put popupmenu1_CreateFcn into a callback of popupmenu2, it changes the popupmenu2 instead of 1. The same, when I put listbox_CreateFcn into the callback of a button, it will stuff the things into the button. How can I say "now refresh the (relevant) menu/list"?
Thanks,
Jana

Best Answer

Jana - the _CreateFcn only gets called when the GUI is launched and the widgets/controls are created. You do not want to be calling this function once the GUI is running. If you have added code to this function that you wish to invoke at a later time, then you should put it in a separate function (still saved in your GUI m file). Something like
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% invoke function to populate/refresh popupmenu1
refreshPopupMenu1(hObject,handles);
where
function refreshPopupMenu1(hObject,handles)
% do stuff
Then, in your callback for the second popup menu, you would do something like
function popupmenu1_Callback(hObject, eventdata, handles)
refreshPopupMenu1(hObject,handles);
You would do the same for the other popu menu and list box.