[Ironruby-core] delegate

Michael Letterle michael.letterle at gmail.com
Wed Feb 6 10:13:39 EST 2008


Well I figured out how to get events wired up, that was fun :)

Personally I'd rather see events wired up like this:

@rbutton.Click.add &Proc
@rbutton.Click.remove &Proc


On Feb 4, 2008 12:40 AM, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote:
> Yes, it's half done and will be fixed. All scenarios that are available in other .NET languages will be doable in Ruby as well.
>
> Tomas
>
>
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Michael Letterle
> Sent: Sunday, February 03, 2008 2:29 PM
> To: ironruby-core at rubyforge.org
> Subject: Re: [Ironruby-core] delegate
>
> 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]
> http://michaeldotnet.blogspot.com
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>



-- 
Michael Letterle
[Polymath Programmer]
http://michaeldotnet.blogspot.com


More information about the Ironruby-core mailing list