Hellow I worte code this code d = System::EventHandler.new { |sender,e| puts "1" } i run code dispay this error wrong number or type of arguments for `System::EventHandler'' (ArgumentError) The delegate to inform a direction for use -- Posted via http://www.ruby-forum.com/.
I don''t think you''d generally want to be initializing an event handler like that, normally you just want to respond to an event. For instance, let''s say you have a System::Windows::Forms::Button called rbutton, you would do something like the following: rbutton.Click { |sender,e| puts "Clicked!"} Why do you feel the need to new up an EventHandler directly? On Feb 3, 2008 12:12 PM, Kim Byung seok <lists at ruby-forum.com> wrote:> Hellow > I worte code this code > > d = System::EventHandler.new { |sender,e| puts "1" } > > i run code dispay this error > wrong number or type of arguments for `System::EventHandler'' > (ArgumentError) > > The delegate to inform a direction for use > -- > 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
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/.
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
Michael Letterle wrote:> I don''t think you''d generally want to be initializing an event handler > like that, normally you just want to respond to an event. For > instance, let''s say you have a System::Windows::Forms::Button called > rbutton, you would do something like the following: > > rbutton.Click { |sender,e| puts "Clicked!"} > > Why do you feel the need to new up an EventHandler directly? > > > > On Feb 3, 2008 12:12 PM, Kim Byung seok <lists at ruby-forum.com> wrote: >> -- >> 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^^; The use is necessary because this code System::ThreadPool.QueueUserWorItem and System::Windows::Threading::Dispatcher.BeginInvoke Above two cords total delegate connection necessary so i wan''t directly delegate -- Posted via http://www.ruby-forum.com/.
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
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/.
You /could/ do: rbutton.Click {|sender, e| onClick sender} rbutton2.Click {|sender, e| onClick sender} Though that''s still not "true" delegation :) 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 >-- Michael Letterle [Polymath Programmer] http://michaeldotnet.blogspot.com
Does IronRuby work with rspec? -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Michael Letterle Sent: Monday, February 04, 2008 3:29 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] delegate You /could/ do: rbutton.Click {|sender, e| onClick sender} rbutton2.Click {|sender, e| onClick sender} Though that''s still not "true" delegation :) 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 >-- Michael Letterle [Polymath Programmer] http://michaeldotnet.blogspot.com _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
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 > > > > >
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 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 >-- Michael Letterle [Polymath Programmer] http://michaeldotnet.blogspot.com
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 > > > > >
Mike Plavsky:> Does IronRuby work with rspec?Not yet. But we do run our specs through mini_rspec, which uses a subset of rspec features. -John
Wow interesting, is mini_rspec part of IronRuby? Regards, Mike -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of John Lam (DLR) Sent: Monday, February 04, 2008 6:33 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] delegate Mike Plavsky:> Does IronRuby work with rspec?Not yet. But we do run our specs through mini_rspec, which uses a subset of rspec features. -John _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Mike Plavsky:> Wow interesting, is mini_rspec part of IronRuby?Yes - it ships as part of our tests\specs directory. Thanks, -John
Thanks a lot! Tried - works fine! Regards, Mike -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of John Lam (DLR) Sent: Monday, February 04, 2008 7:43 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] delegate Mike Plavsky:> Wow interesting, is mini_rspec part of IronRuby?Yes - it ships as part of our tests\specs directory. Thanks, -John _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
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
Michael Letterle wrote:> 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 > >The actual syntax is no big deal. To work like other .NET languages and to provide the same IDE support, however, event handlers need to be named methods that can be selectively ''wired up'' either in programming code or by selecting a method name using Visual Studio''s Events panel. I have no very strong feelings about the operators ( += and -= or some alternatives ) but I do think that consistency with existing .NET delegation standards is important. best wishes Huw SapphireSteel Software Ruby and Rails In Visual Studio http://www.sapphiresteel.com -- Posted via http://www.ruby-forum.com/.
Once we have the method() method, I imagine that will be a little easier... I had taken a side trip on implementing that when looking at the events stuff, but I really wanted to figure out how to get methods added to events properly, I may take a look at implementing method() (and methods()) next... Unless someone tells me to stop. On Feb 6, 2008 12:48 PM, Huw Collingbourne <lists at ruby-forum.com> wrote:> Michael Letterle wrote: > > 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 > > > > > > The actual syntax is no big deal. To work like other .NET languages and > to provide the same IDE support, however, event handlers need to be > named methods that can be selectively ''wired up'' either in programming > code or by selecting a method name using Visual Studio''s Events panel. I > have no very strong feelings about the operators ( += and -= or some > alternatives ) but I do think that consistency with existing .NET > delegation standards is important. > > > 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