- Add a Main Menu: In the Component Browser, right-click on the figure and select "Add Menu."
- Add Submenus: Right-click on the main menu and select "Add Menu" to create submenus. Repeat for additional levels.
- Ensure Proper Hierarchy: Assign each submenu as a child of the menu directly above it.
A appdesigner menu question
조회 수: 3 (최근 30일)
이전 댓글 표시
- How to increase the number of levels below the menu bar in appdesigner?
- fig(1)
- fig(2)
- i create the “Menu”——fig(1),But it didn't show up the “app.Menu_8” in the fig(2)?
댓글 수: 0
답변 (1개)
Shubham
2024년 10월 7일
To increase submenu levels in App Designer, ensure each menu item is a child of its parent menu.
Here's how this can be done:
Here is an example of a MATLAB App Designer script that implements a multi-level menu bar:
classdef MyApp < matlab.apps.AppBase
properties (Access = public)
UIFigure matlab.ui.Figure
MainMenu matlab.ui.container.Menu
SubMenu1 matlab.ui.container.Menu
SubMenu2 matlab.ui.container.Menu
SubSubMenu1 matlab.ui.container.Menu
end
methods (Access = private)
function createComponents(app)
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'My App';
app.MainMenu = uimenu(app.UIFigure);
app.MainMenu.Text = 'Main Menu';
app.SubMenu1 = uimenu(app.MainMenu);
app.SubMenu1.Text = 'SubMenu 1';
app.SubMenu2 = uimenu(app.MainMenu);
app.SubMenu2.Text = 'SubMenu 2';
app.SubSubMenu1 = uimenu(app.SubMenu1);
app.SubSubMenu1.Text = 'SubSubMenu 1';
app.UIFigure.Visible = 'on';
end
end
methods (Access = public)
function app = MyApp
createComponents(app)
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
function delete(app)
delete(app.UIFigure)
end
end
end
Please note that there is no limit to menu depth in App Designer. Ensuring each submenu is linked correctly to its parent will help manage multi-level menus effectively.
For more information on “uimenu”, refer to the following MathWorks documentation link:
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!