MATLAB: Is it possible to generate a GUI with nested callbacks using GUIDE in MATLAB 7.0 (R14)

callbacksguiguideMATLABnested

GUIDE generates MATLAB files whose callbacks are not nested. I would like to generate a GUI using GUIDE with nested callbacks to facilitate data sharing among the callbacks.

Best Answer

To create a GUI with nested callbacks you can use GUIDE to generate the figure file only, and create the nested callbacks in a MATLAB file. In GUIDE, select Tools->Options->Generate Fig File Only and lay out the GUI as desired. Set the Tag property of the objects in the GUI using the Object Browser or Property Inspector. Save the resulting figure file.
Next create a file to build the GUI. First, open the GUI figure using fig=OPEN('gui.fig');. Then obtain a handle to each of the GUI objects using a command similar to the following: h = FINDOBJ(fig, 'tag', objectTag);. Once you have a handle to each of the GUI objects, you can program the rest of the GUI by following the instructions described in the documentation under "Single MATLAB File Using Nested Functions."
Some useful documentation can be accessed at:
Introduction :: Programming the GUI (MATLABĀ®)