Changing a popup menu by changing an edit text box

1 次查看(过去 30 天)
Sorry for all the questions today guys, but I really appreciate all of your help. So I've learned how to change an edit text box by changing a popup menu but can't seem to figure out how to do the opposite. Is it possible that if someone changes the value of an edit text box, that my popup menu can change automatically? I would assume it'd be some sort of if statement that checks if the values are the same but that seems terribly inefficient so I am guessing I am wrong. Thanks again!

采纳的回答

Sean de Wolski
Sean de Wolski 2012-5-18
The edit uicontrol's callback function should get it's string and set something else in the popup.
More per comments
In this case you should use addlistener() to add a listener to the 'PostSet' 'string' event broadcasted by each edit box. The documentation for addlistener() is here:
The call would look something like this:
for ii = 1:numel(hEdit) %where hEdit is the vector of edit box handles
addlistener(hEdit(ii),'PostSet','string',@(src,evt)set(hPopUp,'value',1))
end
  17 个评论
Sean de Wolski
Sean de Wolski 2012-5-21
Yes. Switch the 'String' and the 'PostSet' in your calls to ADDLISTENER. (doc addlistener to see the correct syntax)
Adam Kaas
Adam Kaas 2012-5-21
Thank you Sean! Still a couple bugs to work out but I should be good to go from here!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by