On 26 Oct, 2004, at 12:44, Leonard Rosenthol wrote:
Following up on some discussions of earlier about how to pass a
"callback function" into a plugin, so that the plugin can call on the
RB app as needed (progress, threading, etc.)
What is the best/approved/recommended method for doing this? Passing
in an AddressOf? REALLoadObjectMethod()? Other?
This only needs to work on Mac OS X and Windows...
I'd advise against _all_ of the above. They are not type-safe, so it
would be quite easy to
make your code crash. There are better ways to do this in RB.
Best idea is to either define an interface, or provide an event in one
of your classes.
If you define an interface, simply provide an API where the user can
attach an object which
implements that interface to use as a callback. When you want to call
the method, use
REALInterfaceRoutine to resolve the function pointer for the method in
the interface, then
call it.
If you use an event, you just need to add the event definition to your
class's event
table. When you want to call the event handler, you can resolve the
event handler
function pointer using REALGetEventInstance(), passing in the entry in
the event table
you wish to resolve a function pointer for.
--
Kind Regards,
James Milne
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|