Class methods for UI callbacks cannot access attributes defines after callback

2 次查看(过去 30 天)
Hi, I have an uifig defined as a class and its callbacks as private methods for browing through a folder list. However, during the callback I found that the all the attributes that comes after the calling back ui is set to empty.
Example code
classdef myUI
properties
ddArray = cell(1,8);
uiFig;
end
methods (Access = private)
function changeSelection(self, src, ~)
idx = %find the index of the src in ddArray
%for example if the idx = 4
% self.ddArray{5:8} is empty
end
end
methods
%%constructor
function self = myUI(varargin)
<initalise self.uifig>
for ii = 1:8
self.ddArray{ii} = uidropdown(self.uifig, ...
'ValueChangedFcn', @self.changeSelection);
end
end
end
end
Is there a work around for this?

采纳的回答

Akshayaa Pandiyan
Akshayaa Pandiyan 2023-6-20
defining the class as an handle solved the problem
classdef myUI < handle

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by