selection=doubleDropMenu({'a','b'},{'foo','bar'});
function choices=doubleDropMenu(list1,list2)
f=doubleDropMenu__create_GUI(list1,list2);
uiwait(f);
h=guidata(f);choices=h.choices;close(f);
end
function f=doubleDropMenu__create_GUI(list1,list2)
f=figure('menu','none','Toolbar','none');
h=struct('f',f);
h.button_ok=uicontrol('Parent',f,...
'Style','pushbutton',...
'Units','Normalized',...
'Position',[0.1 0.1 0.3 0.1],...
'String','OK',...
'Callback',@doubleDropMenu__Callback);
h.button_cancel=uicontrol('Parent',f,...
'Style','pushbutton',...
'Units','Normalized',...
'Position',[0.6 0.1 0.3 0.1],...
'String','cancel',...
'Callback',@doubleDropMenu__Callback);
h.list1=uicontrol('Parent',f,...
'Style','popupmenu',...
'Units','Normalized',...
'Position',[0.1 0.6 0.8 0.2],...
'String',list1);
h.list2=uicontrol('Parent',f,...
'Style','popupmenu',...
'Units','Normalized',...
'Position',[0.1 0.3 0.8 0.2],...
'String',list2);
guidata(h.f,h)
end
function doubleDropMenu__Callback(hObject,eventdata)
h=guidata(hObject);
switch hObject
case h.button_ok
h.choices=[get(h.list1,'Value') get(h.list2,'Value')];
case h.button_cancel
h.choices=[0 0];
end
guidata(h.f,h)
uiresume(h.f)
end
Best Answer