[Ironruby-core] delegate
Alex Young
alex at blackkettle.org
Mon Feb 4 10:30:58 EST 2008
On Mon, 2008-02-04 at 10:00 -0500, Michael Letterle wrote:
> That's a bit closer to "true" delegation, in that the same method is
> called rather then two seperate methods, but the event handling still
> doesn't work because of the way it generates the AST Rule. Try the
> following:
>
> onClick = Proc.new {|sender, e| puts "Called OnClick!" }
> onClick2 = Proc.new {sender, e| puts "Called OnClick2!"}
>
> rbutton.Click &onClick
> rbutton.Click &onClick2
>
Agreed - it's one step closer, though :-)
--
Alex
> On Feb 4, 2008 8:47 AM, Alex Young <alex at blackkettle.org> wrote:
> >
> > On Mon, 2008-02-04 at 07:28 -0500, Michael Letterle wrote:
> > > You /could/ do:
> > >
> > > rbutton.Click {|sender, e| onClick sender}
> > > rbutton2.Click {|sender, e| onClick sender}
> > >
> > > Though that's still not "true" delegation :)
> > >
> >
> > Surely:
> >
> > on_click_handler = Proc.new {|sender, e| puts "Clicked"}
> >
> > rbutton.Click &on_click_handler
> > lbutton.Click &on_click_handler
> >
> > would do the trick here? Have I missed something? It's not impossible
> > to also have:
> >
> > rbutton.Click -= on_click_handler
> >
> > later, if you want...
> >
> > --
> > Alex
> >
> >
> > > On Feb 4, 2008 5:56 AM, Huw Collingbourne <lists at ruby-forum.com> wrote:
> > > > Michael Letterle wrote:
> > > > > 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!"}
> > > > >
> > > >
> > > > That's still not quite delegation in the usual sense. What if we have:
> > > >
> > > > def onClick( sender )
> > > > # do something
> > > > end
> > > >
> > > > ...then have this single method 'wired up' to the Click events on, say,
> > > > the 50+ buttons of a scientific calculator? In short, the delegated
> > > > methods need to be detached from specific objects. I'm sure the IronRuby
> > > > team will provide this in time. It makes a big difference when it comes
> > > > to implementing code+form integration ;-)
> > > >
> > > >
> > > > 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
> > > >
> > >
> > >
> > >
> >
> > _______________________________________________
> > Ironruby-core mailing list
> > Ironruby-core at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/ironruby-core
> >
>
>
>
More information about the Ironruby-core
mailing list