Class methods for UI callbacks cannot access attributes defines after callback

6 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Akshayaa Pandiyan
Akshayaa Pandiyan el 20 de Jun. de 2023
defining the class as an handle solved the problem
classdef myUI < handle

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by