| Description |
This function MenuBar, allows the user to create menu's anywhere in a figure
it replaces UIcontextmenu of UIpanels by real menu bars.
menubar(figure_handle) or menubar
Mouse hover, and window-resize updates can be enabled by
menubar('start',figure_handle) or menubar('start')
Or alternatively by:
set(figure_handle,'ResizeFcn','menubar(''ResizeFcn'',gcf)');
set(figure_handle,'WindowButtonMotionFcn','menubar(''MotionFcn'',gcf)');
Example,
%Creat figure with uipanel
figure,
uipanel1 = uipanel('Units','Pixels','Position',[10 200 400 200]);
%Attach a contextmenu (right-mouse button menu)
menu_panel1=uicontextmenu;
set(uipanel1,'UIContextMenu',menu_panel1);
%Add menu-items to the context menu
hchild=uimenu(menu_panel1, 'Label', 'Random Pixels');
uimenu(hchild, 'Label', 'Red','Callback','disp(''Red callback'')');
uimenu(hchild, 'Label', 'Blue','Callback','disp(''Blue callback'')');
%Make form the context menu a real menubar
menubar
%Add some other menu-buttons
hchild=uimenu(menu_panel1, 'Label', 'Clear','Callback','disp(''Clear'')');
hchild=uimenu(menu_panel1, 'Label', 'Help');
uimenu(hchild, 'Label', 'Info','Callback','disp(''Info callback'')');
%Update the menubar
menubar
%Enable the mouse over and resize effects
menubar('start'); |