changing one popup values from another popup menu with guide

7 Ansichten (letzte 30 Tage)
Elad
Elad am 10 Jul. 2016
Beantwortet: Elad am 19 Jul. 2016
Hello everybody,
I've stumbled with a guide related problem. and would appreciate your help.
I have several option in one popup menu each of those corresponds to different set of options. to be chosen in the second popup menu
I want to choose from the first popup menu and immediately change the values corresponding to this field.
As for now the values in the second popupmeanu change only * when I pressed it twice,* meaning invoke it. so it works but not the way I wanted to. Is there any way to update and implement this change immediately when the user pick the values from the first popup menu?
I've attach the code responsible for this change:
function popupmenu1_Callback(hObject, eventdata, handles)
items = get(hObject,'String');
index_selected = get(hObject,'Value');
handles.DataBlock= items(index_selected,:);
handles.DataBlock
switch handles.DataBlock{:}
case 'B111'
list={'Time';'Version' ; ...}
case 'B116'
list={'Time'; 'Version'; 'Sub_frame_Number'; 'System_FN'}
case 'B123'
..
..
end
handles.current_list
handles.current_list=list;
guidata(hObject,handles)
function popupmenu2_Callback(hObject, eventdata, handles)
set(hObject,'String', handles.current_list );
guidata(hObject,handles);
Thank you for the help,
Elad

Akzeptierte Antwort

Image Analyst
Image Analyst am 10 Jul. 2016
Bearbeitet: Image Analyst am 10 Jul. 2016
Why wait until the user interacts with popup2 to set the items in it? That's your problem. Set the items in popup2 immediately as soon as you know them in the popup1 callback. You can set the values/properties of any other controls in any callback since you have the handles of everything. So in popupmenu1_Callback(), after you determine "list", do this
handles.popupmenu1.String = list; % Preferred/recommended way
Or, if you have an antique version of MATLAB, use set():
set(handles.popupmenu1, 'String', list); % Ancient way
Obviously you'd then also take out any code for setting the items in the popupmenu2 callback.

Weitere Antworten (1)

Elad
Elad am 19 Jul. 2016
Thank you very much.
Elad

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by