Changing a popup menu by changing an edit text box

2 views (last 30 days)
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!

Accepted Answer

Sean de Wolski
Sean de Wolski on 18 May 2012
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 Comments
Sean de Wolski
Sean de Wolski on 21 May 2012
Yes. Switch the 'String' and the 'PostSet' in your calls to ADDLISTENER. (doc addlistener to see the correct syntax)
Adam Kaas
Adam Kaas on 21 May 2012
Thank you Sean! Still a couple bugs to work out but I should be good to go from here!

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!