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.

回答(1 个)

Walter Roberson
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);

类别

Help CenterFile Exchange 中查找有关 Code Execution 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by