A appdesigner menu question

조회 수: 3 (최근 30일)
ni
ni 2023년 6월 9일
답변: Shubham 2024년 10월 7일
  • 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)?

답변 (1개)

Shubham
Shubham 2024년 10월 7일
Hi @ni,
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:
  1. Add a Main Menu: In the Component Browser, right-click on the figure and select "Add Menu."
  2. Add Submenus: Right-click on the main menu and select "Add Menu" to create submenus. Repeat for additional levels.
  3. Ensure Proper Hierarchy: Assign each submenu as a child of the menu directly above it.
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!

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by