Thanks for the comments. I found these few lines in the help doc solved a lot of problems:
* addlistener(eventObject,'EventName',@functionName) ? for an ordinary function. * addlistener(eventObject,'EventName',@Obj.methodName) ? for a method of Obj. * addlistener(eventObject,'EventName',@ClassName.methodName) ? for a static method of the class ClassName.
When I switched my syntax for declaring the addlistener to the '@Obj.methodName' form,(row two), I no longer needed to have my listener ftn declared static. So I'm good. I can declare methods of objects as handlers. What's messing me up is the syntax for ftn handles. Is it fully written up somewhere? There seems to be several ways to do it (not to mention inline aproaches like ,@(h, event) handleEvnt(RTTobj,h, event));
My next effort. Now, I'd like to add a listener to an object that has events defined but I want the handler function to simply be a function defined in a .m file. NOT a classes' member function. Is this possible? For example:
function Mfile() % Top function in a .m file
cls AClassWithEvents(); %This class declares 'EventName' as an event addlistener(cls,'EventName',@AnotherFtnInAnMfile);
function AnotherFtnInAnMfile(varargin) %--I'd like this function to be called when 'EventName' is fired from AClassWithEvents
Is this possible? Doesn't seem to be. I can fire the event but AnotherFtnInAnMfile is never called.