Calling custom class callback?

3 views (last 30 days)
Marc Elpel
Marc Elpel on 11 Mar 2021
I have an app designer class (call it ClassA) which is calling functions in a second class (ClassB), where ClassB needs to have a callback to ClassA. The code appears to correctly pass the function to the Callback, but when trying to use the callback it errors out with "Unrecognized function or variable 'MyCallback'." MyCallback is a public function within ClassA.
MyClassB = ClassB(@MyCallback); % Instantiate Class B passing the Callback
MyClassB.Execute(); % Run my code in Class B
Then in the ClassB Code call the callback:
obj.CallBack_Fcn(); % The callback is stored to this property when ClassB is instantiated (obj is ClassB here)
When readback obj.CallBack_Fcn = @MyCallback; - there is no reference to the class which passed it.
The callback is always the same and based on some online searches I've tried various options including:

Answers (0)


Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!