Class methods for UI callbacks cannot access attributes defines after callback

6 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

Akshayaa Pandiyan
Akshayaa Pandiyan le 20 Juin 2023
defining the class as an handle solved the problem
classdef myUI < handle

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by