Hi, i created a panel with a plot and other stuff, and a menu. I want to display the panel with its content only when i click to a specific tab of the menu. How can i do that? thank you

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 3 月 17 日

1 投票

Us the TabGroupSelectionChanged callback function to set the visibility property of the panel to on/off. Here's what the code might look like if I only wanted to display the panel with Tab2 is visible.
% Selection change function: TabGroup
function TabGroupSelectionChanged(app, event)
selectedTab = app.TabGroup.SelectedTab;
switch selectedTab.Title
case "Tab2"
app.Panel.Visible = 'on';
otherwise
app.Panel.Visible = 'off';
end
end
I would have to set the visibility of the panel to the desired visibilty at launch using the inspector. There is a check box for visible in the Panel Interactivity section of the inspector.

3 件のコメント

Marco Picillo
Marco Picillo 2021 年 3 月 17 日
I have a menu, not a tab group. When i click for example on 'menu2' and on a 'submenu2' i want to display my panel. I think is quite similar, but i don't know ho to fix the problem.
Cris LaPierre
Cris LaPierre 2021 年 3 月 17 日
Ah, sorry. The OP mentioned clicking on a tab. You can add a MenuSelectedFcn callback. For example, to have it appear when selecting Menu2
% Menu selected function: Menu2
function Menu2Selected(app, event)
app.Panel.Visible = 'on';
end
You would have to add the code to turn off visibility to whatever function you use to close the menu.
Marco Picillo
Marco Picillo 2021 年 3 月 18 日
thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Interactive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by