App Designer class properties visibility

Hi all,
I am just learning about classes in Matlab. This morning I had a custom class defined and when using an object of that class in App Designer I would get an interactive list of the objects properties after writing the '.' after the object name. Pretty much like you do for any control on the GUI (example):
However, for some reason, I stopped getting this list for my custom class. Not knowing the reason, I stripped the class down until the bear minimum, thinking it might be a parse problem in the class. But still no success. So eventually I tried the auto generated class template of Matlab and created a basic class called Class1 and tried to use this one in App Designer, but still, I get no interactive list of Properties. My class looks like this:
classdef Class1
properties (Access = public)
Property1
end
methods
function obj = Class1(inputArg1,inputArg2)
obj.Property1 = inputArg1 + inputArg2;
end
function outputArg = method1(obj,inputArg)
outputArg = obj.Property1 + inputArg;
end
end
end
And my app designer code looks like this (just a basic figure, with nothing added:
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
Module = Class1(1,2);
Module.
end
end
So at this point, I would expect after the '.' the list showing me 'Property1' to pop up, but it does not appear.
Any ideas? Thanks.

답변 (1개)

Cristian Berceanu
Cristian Berceanu 2019년 9월 18일

3 개 추천

I found it seems myself the answer to this question, I'll just post it here, in case others run in the same trouble. In order for the drop-down list of properties and methods to be available in Code View, you must fist declare the Module as a property of the app and indicate its class like this:
properties (Access = public)
Module Class1;
end
Then you can further use it in the code and access its public properties and methods:
Untitled.png
Best regards,
Cristian

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2019년 9월 12일

답변:

2019년 9월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by