User`s guide
Creating Graphical User Interfaces (GUIs)
9-21
Creating Graphical User Interfaces (GUIs)
Do not Repopulate Menus on the Mac from Inside Their Callbacks
In R2011a, figures display their menus on the Mac screen menubar instead of across
the top of figure windows. Prior to R2011a, GUIs could create dynamic menus using
callbacks that completely deleted, and then repopulated the contents of menus. But on
a Mac, running a GUI with a menu whose callback changes all items in this manner
can result in the display of a blank menu (no items). The unexpected behavior only
happens when a uimenu callback deletes all submenus (child uimenu components) and
repopulates the menu with a new set of items at the time the menu opens.
In R2011a, on the Mac platform only, uimenu callbacks are no longer able to replace all
submenus during menu selection. Note that repopulating some (not all) menu items does
not create this issue. However, it is not good programming practice to remove and insert
menu items within a menu callback routine.
For more information, see “MATLAB Menus Display at the Top of the Apple Mac Screen”
on page 9-2.
Compatibility Considerations
If you have a uimenu callback that repopulates all of its menu items when you open that
menu, you must change that code if you want it to work on a Mac. For example, your code
might be able to remove and install submenus from outside of the callback that handles
the menu. The callback can also rename, disable, hide, and show submenus instead of
deleting them and creating new ones. The Mac is the only platform impacted by this
incompatibility. Menus on Microsoft Windows, Unix, and Linux continue to behave as
they did in previous releases.