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.
Sean Little (2020). GUIDE with nested callbacks (https://www.mathworks.com/matlabcentral/fileexchange/24127-guide-with-nested-callbacks), MATLAB Central File Exchange. Retrieved .