how to set the value of popup menu in another callback?

7 visualizaciones (últimos 30 días)
Daizong
Daizong el 15 de Feb. de 2013
I want the popup menu string to change to the original whenever I change another field's string value in the GUI. could anyone help out?
thanks

Respuestas (2)

Walter Roberson
Walter Roberson el 15 de Feb. de 2013
set(handles.popupmenu, 'Value', 1)
where popupmenu is replaced by the tag of the pop up menu.

Sean de Wolski
Sean de Wolski el 15 de Feb. de 2013
Editada: Sean de Wolski el 15 de Feb. de 2013
Use addlistener to listen to 'PostSet' events of the string changing in other uicontrols.
function showStringUpdate
%Figure
hFig = figure;
%Listbox
hList = uicontrol('Style','listbox',...
'Units','normalized',...
'Position',[0.5 0.1 0.3 0.5],...
'String',{'Hello World','It''s Friday','And a Three day Weekend!'},...
'Max',1,... %Increase for multiselect
'Value',1,...
'Callback',[]);
%Editboxes
for ii = 3:-1:1
h(ii) = uicontrol('Style','edit',...
'Units','normalized',...
'Position',[0.1 0.1*ii 0.3 0.1],...
'String','Type in Me',...
'Callback',[]);
addlistener(h(ii),'String','PostSet',@(src,evt)set(hList,'Value',1));
end
end
Save this, move the listbox selection to something else, and then type in any box.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by