MATLAB Creating Graphical User Interfaces

(ff) #1
startbtn_Callback

The startbtn_Callback function calls the start method of the timer object if the
timer is not already running.

if strcmp(get(handles.timer, 'Running'), 'off')
start(handles.timer);
end

stopbtn_Callback

The stopbtn_Callback function calls the stop method of the timer object if the timer
is currently running.

if strcmp(get(handles.timer, 'Running'), 'on')
stop(handles.timer);
end

figure1_CloseRequestFcn

The figure1_CloseRequestFcn callback executes when the user closes the app. The
function stops the timer object if it is running, deletes the timer object, and then
deletes the figure window.

if strcmp(get(handles.timer, 'Running'), 'on')
stop(handles.timer);
end
% Destroy timer
delete(handles.timer)
% Destroy figure
delete(hObject);

See Also


Related Examples



  • “Timer Callback Functions”

  • “Write Callbacks in GUIDE” on page 7-2


8 Examples of GUIDE UIs

Free download pdf