Changing a popup menu by changing an edit text box

3 vues (au cours des 30 derniers jours)
Adam Kaas
Adam Kaas le 18 Mai 2012
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!

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by