MATLAB: How to add a graphics object callback subfunction to a GUI MATLAB program using GUIDE in MATLAB

buttondownfcncallbackcloserequestfcncreatefcndeletefcnkeypressfcnMATLABresizefcnwindowbuttondownfcnwindowbuttonmotionfcnwindowbuttonupfcn

I want to add a graphics object callback subfunction, such as 'ButtonDownFcn', to my GUI MATLAB program using GUIDE.

Best Answer

Graphics objects can have additional callback routines like ButtonDownFcn, CreateFcn, and DeleteFcn, which are executed with the appropriate user action.
Figures can also have the following callbacks:
CloseRequestFcn
KeyPressFcn
ResizeFcn
WindowButtonDownFcn
WindowButtonMotionFcn
WindowButtonUpFcn
To add a callback subfunction to the MATLAB program:
1. Click the right mouse button while the object is selected to display the Layout Editor context menu
2. Select View Callbacks
3. Select the desired callback from the context menu
GUIDE then adds the subfunction stub to the MATLAB program file for the GUI.
For more information on this, visit the following documentation page on our web site:
<http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f10-1005070.html#f10-999362>