필터 지우기
필터 지우기

forbid the switch of tab group in app designer while running a calculation

조회 수: 5 (최근 30일)
Yang Yang
Yang Yang 2020년 1월 12일
답변: Yang Yang 2020년 1월 25일
How can I forbid user to switch to another tab in a tab group in app designer?
I have an implementation with multiple tabs dedicated to different calculations. When running a calculation in one specific tab, which takes a couple of minutes, the user is still capable of switching to a different tab, which sometimes can screw up the calculation. How can I forbid the user to do such operation?
thanks!

답변 (2개)

Cameron B
Cameron B 2020년 1월 13일
편집: Cameron B 2020년 1월 13일
It doesn't look as if I can attach my mlapp file so I'll paste the relevant code here and let you put it together. When you hit the button marked "Count to 10" it will begin counting and will not allow the user to change tabs until the callback function is complete.Once complete, it will assign a value of 1 to IsFinished which allows the tabs to be changed.
%i don't know why properties and methods aren't shown as blue, but they should be. not a big deal
properties (Access = private)
IsFinished = 1; %allows tabs to be changed at beginning
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Countto10Button
function Countto10ButtonPushed(app, event)
app.IsFinished = 0; %stops tabs from being changed
app.Countto10Button.BackgroundColor = 'r';
for bb = 1:10
app.EditField.Value = bb;
pause(1)
end
app.IsFinished = 1; %allows tab to be changed
app.Countto10Button.BackgroundColor = 'g';
end
% Selection change function: TabGroup
function TabGroupSelectionChanged(app, event)
app.TabGroup.BusyAction = 'Cancel';
if app.IsFinished == 1 %don't run this if the Count button isn't pressed.
return
end
%if the selected tab is anything other than 'Stay', then run this
if ~strcmpi(app.TabGroup.SelectedTab.Title,'Stay')
app.TabGroup.SelectedTab = app.TabGroup.Children(1);
end
end
end

Yang Yang
Yang Yang 2020년 1월 25일
thank you very much Cameron B!
I ended up not having to using this feature by removing some of the functionality.
But your solution is great and will be useful in future!

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by