MATLAB Creating Graphical User Interfaces

(ff) #1

using uimenu to create menu items. Note that context menus do not have an
Accelerator property.


NoteAfter you have created the context menu and all its items, set their
HandleVisibility properties to 'off' by executing the following statements:


cmenuhandles = findall(figurehandle,'type','uicontextmenu');
cmenuhandles.HandleVisibility = 'off';
menuitemhandles = findall(cmenuhandles,'type','uimenu');
menuitemhandles.HandleVisibility = 'off';


Associate the Context Menu with Graphics Objects


You can associate a context menu with the figure itself and with all components that have
a UIContextMenu property. This includes axes, panel, button group, all user interface
controls (uicontrols).


This code adds a panel and an axes to the figure. The panel contains a single push button.


ph = uipanel('Parent',fh,'Units','pixels',...
'Position',[20 40 150 150]);
bh1 = uicontrol(ph,'String','Button 1',...
'Position',[20 20 60 40]);
ah = axes('Parent',fh,'Units','pixels',...
'Position',[220 40 150 150]);


Create Menus for Programmatic Apps
Free download pdf