Callback
Property
User Action Components That Use This
Property
WindowButtonM
otionFcn
End user moves the pointer within
the figure window.
figure
WindowButtonU
pFcn
End user releases a mouse button. figure
WindowKeyPres
sFcn
End user presses a key while the
pointer is on the figure or any of
its child objects.
figure
WindowKeyRele
aseFcn
End user releases a key while the
pointer is on the figure or any of
its child objects.
figure
WindowScrollW
heelFcn
End user turns the mouse wheel
while the pointer is on the figure.
figure
GUIDE-Generated Callback Functions and Property Values
How GUIDE Manages Callback Functions and Properties
After you add a uicontrol, uimenu, or uicontextmenu component to your UI, but
before you save it, GUIDE populates the Callback property with the value, %automatic.
This value indicates that GUIDE will generate a name for the callback function.
When you save your UI, GUIDE adds an empty callback function definition to your code
file, and it sets the control’s Callback property to be an anonymous function. This
function definition is an example of a GUIDE-generated callback function for a push
button.
function pushbutton1_Callback(hObject,eventdata,handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
end
If you save this UI with the name, myui, then GUIDE sets the push button’s Callback
property to the following value:
@(hObject,eventdata)myui('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
This is an anonymous function that serves as a reference to the function,
pushbutton1_Callback. This anonymous function has four input arguments. The first
7 Programming a GUIDE App