[Ironruby-core] delegate

Michael Letterle michael.letterle at gmail.com
Sun Feb 3 17:28:57 EST 2008

Well, it seems like the event stuff is only half done, let's say you
add two additional blocks to the Click event.  You'll actually fire
three methods, except it will only be the first one you defined (ie
It'll say "Clicked!" three times).  It seems to have something to do
with the way SetInvocationRule is currently implemented in
RubyEventInfo.  I'm sure this'll be fixed eventually :)

What I'm saying is eventually you'll be able to something like

rbutton.Click{|sender, e| puts "Clicked!"}
rbutton.Click{|sender, e| puts "Also Clicked!"}

and it'll work like +=ing to two seperate functions.

On Feb 3, 2008 2:48 PM, Huw Collingbourne <lists at ruby-forum.com> wrote:
> Michael Letterle wrote:
> > rbutton.Click { |sender,e| puts "Clicked!"}
> >
> > Why do you feel the need to new up an EventHandler directly?
> The problem is that this does not providee the ability (as in all other
> .NET languages) to do true delegation. In C#, for example, it is
> perfectly posssible to delegate the same event handling method to large
> numbers of different controls. We have already 'faked' delegation in a
> similar way to your suggestion (attaching blocks to specific
> Control.events) in our current form designer for IronRuby:
> http://www.sapphiresteel.com/IronRuby-Visual-Form-Designer
> http://www.sapphiresteel.com/IronRuby-Visual-Designer
> For a production system, however, this is less than desirable. What we
> really need is the normal .NET type of delegate chaining using the +=
> and -= operators.
> best wishes
> Huw
> SapphireSteel Software
> Ruby and Rails In Visual Studio
> http://www.sapphiresteel.com
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core

Michael Letterle
[Polymath Programmer]

More information about the Ironruby-core mailing list