How to make GUI components like edit, slider or popup-menu not to be passive in the first run of gui?
2 ビュー (過去 30 日間)
古いコメントを表示
In my GUI, components like edit, slider, and popup menus are passive till they get touched. I have to touch them so they get active and to make a field in hObject. To be specific, I have three slider for combining red, green, and blue colors. I use them in a plot (in a separate callback function) for making line and marker properties. However, they are passive (causing the error 'Reference to non-existent field'). I have to touch all three slider (making a field for each one) to get my plot.
When I try to use current_values that are introduced in GUI's opening function I have to make a logical choice (if), but I don't know how to express 'non-existent' filed as a choice. My GUI's function is look like:
gui_OpeningFcn
current_red = 0.5;
current_green = 0.5
current_blue = 0.5
redslider_Function
redsv = get(hObject,'Value');
handles.redsv = redsv;
guidata(hObject,handles)
and those of green and blue
pushbotton_Function
redsv= handles.redsv
greensv = handles.green
bluesv = handles.blue
figure (1)
plot (x,y, 'color', [redsv, greensv, bluesv])
or
if ~isfield(handles.'redsv') && ~isfield(handles.'greensv') && ~isfield(handles.'bluesv')
plot(x,y, 'color', [current_red, current_green, current_blue])
else
plot(x,y, 'color', [redsv, greensv, bluesv])
end
And, I don't want to introduce a plot in opening function.
I'll be thankful if somebody show the correct way.
0 件のコメント
回答 (1 件)
Walter Roberson
2015 年 8 月 6 日
gui_OpeningFcn:
current_red = 0.5;
current_green = 0.5
current_blue = 0.5
handles.redsv = current_red;
handles.greensv = current_green;
handles.bluesv = current_blue;
guidata(gcbo, handles);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!