
forbid the switch of tab group in app designer while running a calculation
    7 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
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!
0 commentaires
Réponses (2)
  Cameron B
      
 le 13 Jan 2020
        
      Modifié(e) : Cameron B
      
 le 13 Jan 2020
  
      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

0 commentaires
Voir également
Catégories
				En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

