How to make GUI components like edit, slider or popup-menu not to be passive in the first run of gui?
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 6 Aug 2015
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 Comments
See Also
Categories
Find more on Code Execution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!