The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Static Callback Methods?
Replies: 6   Last Post: Aug 5, 2010 5:01 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Joe Burgel

Posts: 25
Registered: 12/7/04
Re: Static Callback Methods?
Posted: Aug 4, 2010 5:36 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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
written up somewhere? There seems to be several ways to do it (not to
mention inline aproaches like ,@(h, event) handleEvnt(RTTobj,h,

New Problem:

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

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.

Any help is appreciated.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.