Named arguments of .mlapp don't auto complete
    9 views (last 30 days)
  
       Show older comments
    
Are named arguments of mlapp (AppDesigner) methods not auto completed?
For example, putting this into a class in a m file works:
classdef app1 < matlab.apps.AppBase
    % Properties that correspond to app components
    properties (Access = public)
        UIFigure  matlab.ui.Figure
    end
    methods (Access = public)
        function results = func(app, opts)
            arguments
                app 
                opts.Option1 = "jo"
                opts.Option2 = "haha"
            end
        end
    end
    % Component initialization
    methods (Access = private)
        % Create UIFigure and components
        function createComponents(app)
            % Create UIFigure and hide until all components are created
            app.UIFigure = uifigure('Visible', 'off');
            app.UIFigure.Position = [100 100 640 480];
            app.UIFigure.Name = 'MATLAB App';
            % Show the figure after all components are created
            app.UIFigure.Visible = 'on';
        end
    end
    % App creation and deletion
    methods (Access = public)
        % Construct app
        function app = app1
            % Create UIFigure and components
            createComponents(app)
            % Register the app with App Designer
            registerApp(app, app.UIFigure)
            if nargout == 0
                clear app
            end
        end
        % Code that executes before app deletion
        function delete(app)
            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end
called via
h = app1;
h.func()
works as expected:

Using the AppDesigner to use the same code, auto completion does not work:

Why? Is the code in an .mlapp handled differently? 
0 Comments
Answers (1)
  Ayush Singh
      
 on 17 Jun 2024
        
      Edited: Ayush Singh
      
 on 18 Jun 2024
  
      Hi Jan,
I tried the same steps at my end and I was able to get the auto completion option in App Designer as well.
Suppose you add the above code in App Designer and now when you add the following code to any other function inside App Designer:
    methods (Access = public)
        function results = func3(app)
                  h=app1;
                  h.func("Option1")  % this Option1 is auto completed
        end
    end
    end
You will get the similar auto completion like the one you received for MATLAB file.
0 Comments
See Also
Categories
				Find more on Develop Apps Using App Designer in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
