Named arguments of .mlapp don't auto complete

1 view (last 30 days)
Jan Kappen
Jan Kappen on 13 Jun 2024
Edited: Ayush Singh on 18 Jun 2024
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?

Answers (1)

Ayush Singh
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.

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!