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

Jan
Jan 2018년 11월 8일
What does this mean: "go back to the first option"? What is going to where?
Abdullah Andergeery
Abdullah Andergeery 2018년 11월 8일
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.
Jan
Jan 2018년 11월 8일
Please post the code of the callback. Maybe a screenshot clarifies, what "go to the first option" means.
Abdullah Andergeery
Abdullah Andergeery 2018년 11월 8일
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일

0 개 추천

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');
Jan
Jan 2018년 11월 9일
편집: Jan 2018년 11월 9일
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);
Abdullah Andergeery
Abdullah Andergeery 2018년 11월 9일
thank you A looot that did work, but i used "Items" rather than "DataItems". Do you what is the different between "Items" ,and "DataItems" ?
Guillaume
Guillaume 2018년 11월 11일
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개)

카테고리

질문:

2018년 11월 7일

댓글:

2018년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by