フィルターのクリア

Is there a way in enable and disable tabs in Matlab?

31 ビュー (過去 30 日間)
Sean
Sean 2023 年 9 月 13 日
回答済み: Sean 2023 年 9 月 20 日
I've been trying to be able to enable and disable the ability to go into a tab depending on the value of a
app.NumberOfTabsDropDown.Value
I tried switch cases for the callback, but I get a test case where it's not valid
function TabGroupSelectionChanged(app,event)
selectedTab = app.TabGroup.SelectedTab;
numberOfTabs = app.NumberOfTabsDropDown.Value; % It can only select 1 to 4
% We don't need to check for Tab 1
switch selectedTab.Title
case 'Tab 2'
switch numberOfTabs
case '1'
app.TabGroup.SelectedTab = event.OldValue;
case '2'
return
case '3'
return
case '4'
return
end
case 'Tab 3'
switch numberOfTabs
case '1'
app.TabGroup.SelectedTab = event.OldValue;
case '2'
app.TabGroup.SelectedTab = event.OldValue;
case '3'
return
case '4'
return
end
case 'Tab 4'
switch numberOfTabs
case '1'
app.TabGroup.SelectedTab = event.OldValue;
case '2'
app.TabGroup.SelectedTab = event.OldValue;
case '3'
app.TabGroup.SelectedTab = event.OldValue;
case '4'
return
end
end
end
The code works, but there is a case if I change the app.NumberOfTabsDropDown.Value = 2 while I'm currently on 'Tab 4' and click on 'Tab 3', it goes back to 'Tab 4'. Is there a way to go back to the selected or can you equal it to itself? I feel like I just solved it, just by writing this out, but any comments or solutions would be helpful. (I tried to do an is statement, but it keeps on messing up and more cases arise.)
case 'Tab 2'
if app.NumberOfTabs.Value > 2
app.TabGroup.SeletedTab = event.OldValue;
end
case 'Tab 3'
if app.NumberOfTabs.Value > 3
app.TabGroup.SeletedTab = event.OldValue;
end
case 'Tab 4'
if app.NumberOfTabs.Value > 4
app.TabGroup.SeletedTab = event.OldValue;
end
I would appreciate the help, if you guys can!

採用された回答

Sean
Sean 2023 年 9 月 20 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by