Named arguments of .mlapp don't auto complete
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!