At 8:18 AM -0700 14/2/06, Joseph J. Strout wrote:
At 9:13 AM -0500 2/14/06, Michael wrote:

Taking this a little further, if I were to create an array of push button
control objects, is there any way to programmatically assign different
actions to the buttons in the array?

There is, actually, though it's a bit obscure. The PushButton class implements the ActionSource interface, which means that it has an addActionNotificationReceiver method. This method takes, as a parameter, any object that implements the actionNotificationReceiver interface. So you can:

1. Create a class that has "actionNotificationReceiver" among its interfaces. Such a class will therefore have a PerformAction method.

2. On your new pushbutton (let's call it pb), add an instance of your class (let's call it thing) like so:

  pb.addActionNotificationReceiver thing

3. There's no step three! Now, whenever somebody clicks the pb button, thing's PerformAction method will be called.

This isn't necessarily the best way to solve your real problem (another way would be to keep a dictionary that maps pushbuttons to some sort of action, and simply look 'me' up in the button's Action event and act accordingly), but it certainly is a nifty bit of RB trivia, wouldn't you say?

Best,
- Joe


How do we find out what interfaces the built-in classes implements?
Are these documented at all?
--

Cheers,

Dr Gerard Hammond
Bioinformatic Analyst
Garvan Institute of Medical Research, Sydney, Australia.

Bioinformatics is the science of managing, mining and interpreting information from biological and clinical data, including sequences, structures, gene expression profiles, mass spectra and medical records.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to