A appdesigner menu question

3 visualizzazioni (ultimi 30 giorni)
ni
ni il 9 Giu 2023
Risposto: Shubham il 7 Ott 2024
  • 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)?

Risposte (1)

Shubham
Shubham il 7 Ott 2024
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!

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by