realbasic-nug
[Top] [All Lists]

Some questions about delegates

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Some questions about delegates
From: Dave Addey <listmail1 at addey dot com>
Date: Fri, 30 Nov 2007 21:17:25 +0000
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Thread-index: Acgzlmc5pYX46p+JEdycPwAbY5gHRw==
Thread-topic: Some questions about delegates
I¹m working on my RBScript-based controller code, and it¹s all going well ­
but I have one more challenge....

I¹ve created a generic ³Controller² class.  The code for the controller is
in an RBscript. I want to be able to register a callback, which will call a
callback method on a controller class instance.  I think this might be where
I should use delegates?

Historically, I¹ve always had to use global module methods for callbacks.
This has the downside that I don¹t know (from within the callback) which
controller object triggered the callback.  Since my different controller
types may need to use the same callback template (e.g. two UInt32 params,
returning a UInt32), I won¹t even know which type of controller caused the
callback, let alone which instance of the controller, in order to pass the
callback event on to the controller for processing.

I¹m rather hoping that delegates give me a way to set up these callbacks
using class-instance methods as the callback target.  But I can¹t work out
what the code would be to do this.  Do I need to define a delegate in a
module?  Do I need a property on the class to represent the callback method?
Where would the callback code go?

Any help much appreciated!

Dave.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>