Hello - I'm trying to get two buttons to become Enabled after two other buttons have been pressed. I'm not sure what I'm doing wrong here, but I'm pretty new to MATLAB and am likely making a silly mistake. This was a procedurally made GUI.
I set up the handles structure:
fighandl=figure;
handles = guihandles(fighandl);
handles.firstVis = 0;
handles.secondVis = 0;
guidata(fighandl,handles);
Here's the code for the button creation (only including what's necessary):
push1=uicontrol('Style','pushbutton',...
'String','Play Excerpt 1',...
'Units','Normalized',...
'Position',[0.05 0.6 0.4 0.3],...
'Callback',@push1_Callback);
push2=uicontrol('Style','pushbutton',...
'String','Play Excerpt 2',...
'Units','Normalized',...
'Position',[0.55 0.6 0.4 0.3],...
'Callback',@push2_Callback);
handles.push3=uicontrol('Style','pushbutton',...
'String','Prefer Excerpt 1',...
'Position',[0.05 0.3 0.4 0.2],...
'Enable','off',...
'Callback',@push3_Callback);
handles.push4=uicontrol('Style','pushbutton',...
'String','Prefer Excerpt 2',...
'Position',[0.55 0.3 0.4 0.2],...
'Enable','off',...
'Callback',@push4_Callback);
And here are the callback functions (I'm only including the two that play a role in enabling push3 and push4, which are virtually identical):
function push1_Callback(push1, eventdata, handles, whichsound)
handles = guidata(gcf);
handles.firstVis = handles.firstVis+1;
if (handles.firstVis>=1 && handles.secondVis>=1)
disp('Yay');
set(handles.push3,'Enable','on');
set(handles.push4,'Enable','on');
end
guidata(gcf,handles)
And the second function
function push2_Callback(push2, eventdata, handles, whichsound)
handles = guidata(gcf);
handles.secondVis = handles.secondVis+1;
if (handles.firstVis>=1 && handles.secondVis>=1)
disp('Yay');
set(handles.push3,'Enable','on');
set(handles.push4,'Enable','on');
end
guidata(gcf,handles)