필터 지우기
필터 지우기

How to make GUI components like edit, slider or popup-menu not to be passive in the first run of gui?

조회 수: 1 (최근 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에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by