File Exchange

image thumbnail

GUIDE with nested callbacks

version (7.08 KB) by Sean Little
Utility that automatically generates m-files with nested callbacks.


Updated 01 Sep 2016

View License

Tired of using USERDATA or GUIDATA calls to share data between callbacks in GUIDE? Nested callbacks are the answer. A nested function can "see" all the data that the top level function can. You therefore no longer need to painstakingly save or pass data for later use.
Unfortunately, up until now using nested functions meant giving up the convenience of using GUIDE to define the layout of your GUI. GUIDE does not natively support nested callbacks. This utility solves that problem.
First do all the layout of GUI objects in GUIDE. Then use the Tools -> GUI Options menu to select "Generate FIG file only". Then call the enclosed NESTED_GUI function according to the documented syntax such as the following:

>> nested_gui my_gui.fig

An m-file called "my_gui.m" will then be automatically generated that uses nested callback functions.

Note that this utility can also replace the FIG file with a text file that can be edited and used in a code repository. I call this "text layout mode". See the header help for more details.

Please note that I have assumed that users of this function have a certain familiarity with MATLAB and GUIDE. If you are new to MATLAB and GUI creation, I suggest that you read about GUIDE and nested functions before you attempt to use this utility.

Cite As

Sean Little (2020). GUIDE with nested callbacks (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)


Updated license


MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux