User`s guide

15 Examples of GUIs Created Programmatically
Define the Callbacks
This topic defines the callbacks that service the components of the GUI.
Because the callback definitions are at a lower level than the component
definitions and the data created for the GUI, they have access to all data
and component handles.
Although the GUI has six com ponents that are serviced b y callbacks, there
are only four callback functions. This is because the Open menu item and the
Open toolbar button
share the same callbacks. Similarly, the Print menu
item and the Print toolbar button
share the same callbacks.
“Update Button Callback” on page 15-14
“Open Menu Item Callback” on page 15-15
“Print M enu Item Callback” on page 15-16
“Close Menu Item Callback” on page 15-17
Note These are the callbacks that were specified in the component definitions,
“Create the GUI and Its Components” on page 15-8.
Update Button Callback
The hUpdateButtonCallback function services the Update push button.
Clicking the Update button triggers the execution of this callback function.
function hUpdat eBut tonCallback(hObject, eventdata)
% Callback function run when the Update but ton is pressed
localUpdatePlot();
end
The localUpdatePlot function is a helper function that plots the selected plot
type in the axes. It is defined later in the script, “Helper Function: Plot the
Plot Types” on page 15-18.
15-14