Named arguments of .mlapp don't auto complete

조회 수: 1 (최근 30일)
Jan Kappen
Jan Kappen 2024년 6월 13일
편집: Ayush Singh 2024년 6월 18일
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?

답변 (1개)

Ayush Singh
Ayush Singh 2024년 6월 17일
편집: Ayush Singh 2024년 6월 18일
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.

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by