필터 지우기
필터 지우기

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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by