Hi guys,
I'm having some problems with event in classes. I have a class class like this:
classdef ClassA < handle properties prop end events EventA end methods function o = ClassA addlistener(o,'EventA',@o.callbackfun); o.prop = ClassB; end function callbackfun(o,~,~) % do something
end endend
and the ClassB like:
classdef ClassB < handle properties button end methods function o = ClassB fig = figure; o.button = uicontrol(fig,'Style','pushbutton','Callback',@(~,~,~) notify(ClassA,'EventA')); end endend
And then, when I click the button, it opens a new figure. Like it was calling ClassA again. What I am doing wrong?
Thanks,
Best Answer