[Ironruby-core] .Net Events in IR

Kevin Radcliffe lists at ruby-forum.com
Sat Jul 11 19:43:14 EDT 2009


Shay Friedman wrote:
> Hi there,
> 
> I know that I can register and handle .Net events in IronRuby in the
> following way:
> klass.some_event { |sender, args| puts "Hello!" }
> 
> Is this the only way of doing so or are there more ways?
> 
> Thanks!
> Shay.
> ----------------------------
> Shay Friedman
> http://www.ironshay.com
> Follow me: http://twitter.com/ironshay

What are you looking to do currently, is there something specific you 
want to accomplish?

You are sending a block, so this could be multi-line with do/end . Also, 
(depending on the context of your program), you could forgo the |sender, 
args| :

button.click do
 puts "Something..."
 puts "Very interesting.."
end

I've attached a very simple Windows Forms app which shows this method of 
hooking up an event, firing it manually through code, and then bringing 
up the GUI...
-- 
Posted via http://www.ruby-forum.com/.


More information about the Ironruby-core mailing list