Help defining a callback to enable a pushbutton
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, in a long script that I'm working on, I don't manage that a pushbutton is activated when something happens. Here's the code:
%Tex uicontrols that once they change to a specific colour, which means the user input is correct, then they enable a pushbutton.
texpd0 = uicontrol(pdp,'Style','text','String','Drop Height:','BackgroundColor',[.88 .88 .88],'Position',[15 85 125 20],'FontSize',12,'Callback',@act);
expd2 = uicontrol(pdp,'Style','text','String','PI Elevation:','BackgroundColor',[.88 .88 .88],'Position',[15 25 125 20],'FontSize',12,'Callback',@act);
texpd4 = uicontrol(pdp,'Style','text','String','ISA dev:','BackgroundColor',[.88 .88 .88],'Position',[200 200 80 20],'FontSize',12,'Callback',@act);
texpd5 = uicontrol(pdp,'Style','text','String','IASact:','BackgroundColor',[.88 .88 .88],'Position',[200 170 80 20],'FontSize',12,'Callback',@act);
%This is the pushbutton that should be enabled. Default is unabled.
edt6a = uicontrol(pdp,'Style','pushbutton','String','Update TAS','Position',[360 140 70 20],'Enable','off','Callback',@update)
%Here the callback function of the tex uicontrols:
function act
cond0 = get(texpd0,'BackgroundColor');
cond1 = get(texpd2,'BackgroundColor');
cond2 = get(texpd4,'BackgroundColor');
cond5 = get(texpd5,'BackgroundColor');
ok = [.88 .96 .88];
if isequal(cond0,ok) && isequal(cond1,ok) && isequal(cond2,ok) && isequal(cond5,ok)
set(edt6a,'Enable','on');
else
set(edt6a,'Enable','off');
end
end
So what I want to achieve is that when all these tex uicontrols change its backgroundcolor to [.88 .96 .88], then the pushbutton is enabled.
0 Kommentare
Antworten (1)
Adam
am 1 Dez. 2014
In what way does it not work? Does the act function even get called? If it does I'm guessing from your function signature that it has an empty workspace since it takes no input arguments.
From what you have written the 'act' function will not know what texpd0 and the others are. You would likely need to put these all together in a struct and pass that to your act function as an input argument.
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!