drop down return to the first option

Hello, I have created drop down menu using GUI, using {option 1, ......4}
each option play a sound How to go back to first option, "option 1" after the sound ends. I want be always to go back to the first option once the sound ends, or how to rest the drop down menu to the first the option at the top of the menu
value = app.PickASoundDropDown_Black_Sp.Value;
if strcmp(value, 'Click')
clear all ; close all
app.chan_Black_Sp = 0;
elseif strcmp(value, 'Browse a File')
file = uigetfile('*wav','Select Channel 2 Audio File');
end
so, I want to go back to "Click" after I have picked an audio file is done playing.

4 个评论

What does this mean: "go back to the first option"? What is going to where?
the drop down menu go to the first option 1 after I pick up for example option 4, I do not the app hang on option 4 and its value.
Please post the code of the callback. Maybe a screenshot clarifies, what "go to the first option" means.
here is an image so now the dropdown menu is on "click" which is give a command of make red channel = 0 if i pick for example the sound of rain then it going to play sound of rain and the drop down menu will stay on sound of rain option without going back to "click" I hope you can understand what I mean

请先登录,再进行评论。

 采纳的回答

Guillaume
Guillaume 2018-11-8
If you're using a uidropdown in app designer, at the end of your callback, after you've emitted your sound, set the dropdown Value property to your uidropdown ItemData(1) value.
If you're using a uicontrol of style 'popupmenu', set its Value property to 1 instead.

6 个评论

this not working.
if true
% code
value = app.PickASoundDropDown_Black_Sp.Value;
if strcmp(value, 'Click')
clear all ; close all
app.chan_Black_Sp = 0;
elseif strcmp(value, 'Browse a File')
file = uigetfile('*wav','Select Channel 2 Audio File');
[y,Fs] = audioread(file)
value= DataItems(1);
end
I also tried
value= DataItems('Click');
Please explain "is not working" with details, preferably the error message.
What is "DataItems"?
Do you mean:
app.PickASoundDropDown_Black_Sp.Value = 1
?
ops! I tried this
if s.IsDone
value=ItemsData(1) ;
end
Setting the variable value to whatever is never going to affect the dropdown itself. You need to tell matlab it's the dropdown value you want to change, so:
app.PickASoundDropDown_Black_Sp.Value = app.PickASoundDropDown_Black_Sp.DataItems(1);
thank you A looot that did work, but i used "Items" rather than "DataItems". Do you what is the different between "Items" ,and "DataItems" ?
DataItems is used to associate values to the drop down selection that is different from what is displayed to the user. If you've left DataItems empty, the Value property will be the Items selected, otherwise it will be the corresponding DataItems.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by