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!