User`s guide
11 Lay Out a Programmatic GUI
You can use any applicable Uimenu Properties such as C heck ed or Separator
when you define context menu items. See the uimenu reference page and “Add
Menu Bar M enus” on page 11-75 for information about using
uimenu to create
menu items. Note that context menus do not have an
Accelerator property.
Note After you ha ve created the context menu and all its item s , set their
HandleVisibility properties to off by executing the following statements:
cmenuhandles = findall(figurehandle,'type','uicontextmenu' );
set(cmenuhandles,'HandleVisibility' ,'off')
menuitemhandles = findall(cmenuhandles,'type','uimenu' );
set(menuitemhandles,'HandleVisibili ty','off')
Associate the Context Menu with Graphics Objects
You can associate a c ontext 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).
The following code adds a panel and a n 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','Bu tton 1',...
'Position',[20 20 60 40]);
ah = axes('Parent',fh,'Units',' pixels',...
'Position',[220 40 150 150]);
11-84