Suppress callbacks generated by GUIDE

In GUIDE, there is a "View Callbacks" menu option to let one add additional callbacks for a particular uicontrol to the mfile that GUIDE generates. However, is there a way to suppress certain callbacks from being added to the mfile, so as to minimize clutter? There are certain callbacks, e.g., CreateFcn's, for which I know I will always be using the default.

 Accepted Answer

Matt J
Matt J on 27 May 2014
Edited: Matt J on 27 May 2014
You can always retroactively delete the callbacks in the property inspector and in the generated MATLAB file.
Possibly this is what Sean was already implying, but I just discovered that if you delete code for a callback completely from the generated mfile, they won't come back when GUIDE updates the mfile with further changes. To restore a deleted callback, you just have to use the uicontrol's "View Callback" menu option.
This is ultimately what I was looking for. I had assumed, incorrectly, that a GUIDE update would always regenerate callbacks in the mfile for all uicontrols in the GUI.
+1 to Sean and thanks to everyone else.

More Answers (2)

I don't believe so.
You can always retroactively delete the callbacks in the property inspector and in the generated MATLAB file.

6 Comments

Matt J
Matt J on 26 May 2014
Edited: Matt J on 26 May 2014
Hmmm, but then what if I use the "View Callbacks" menu option to make the generated mfile contain a certain callback, but then I want to shut it off? I.e., what if I want to stop viewing the callback that I chose to view earlier?
You want to remove a callback from the code that you wanted to see earlier? Have you considered contacting technical support regarding your question?
Well, it just seems to me like the kind of thing you should be able to turn on and off freely. As it stands, it looks like you can only turn a callback "on".
I have considered taking it to tech support, if the Answers community doesn't know a solution, that is.
Like Sean I do not think it is possible to turn callbacks on and off. Technical support can double check this and also forward enhancement requests to development.
I haven't tried it recently but several years ago if you manually deleted the CreateFcn from the m-file, it caused errors, so I got in the habit of just leaving them in there (as clutter) and ignoring them.
Perhaps (according to what Sean says) you can delete them now, with no harmful effects. So to use one (which I've never had to do), just view the CreateFcn callback (or any callback), and to delete them ("turn them off") you highlight and delete from the m-file in the text editor.
@IA, you can delete them with no harmful effects IF you set them to empty in the property editor as well.
@Matt, "viewing callbacks" automatically creates them, if you don't view them auxiliary ones should not be created. I don't totally understand the use case for not wanting to "not be able to view/create". What about the one time you do want one? If it's not there that will be far more frustrating than occasionally creating some clutter.
If you really are looking to develop an application, I would avoid GUIDE altogether and just use OOP anyway. It might take a little longer to get the layout down but you're in total control of everything and all of the pieces are reusable.

Sign in to comment.

Sean Little
Sean Little on 27 May 2014
I couple years ago I wrote a function that post processes the GUIDE generated FIG and m-file and removes unwanted callback declarations from the FIG file. It also generates a new m-file that uses a nested callback scheme. For anyone who is looking for an automated way to modify the FIG file, you might want to take a look.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Asked:

on 23 May 2014

Answered:

on 27 May 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!