[MacRuby-devel] [MacRuby] #712: Feature Request: Add Support for C-Level Blocks
MacRuby
ruby-noreply at macosforge.org
Thu May 13 09:47:26 PDT 2010
#712: Feature Request: Add Support for C-Level Blocks
-------------------------------+--------------------------------------------
Reporter: cwdinfo@… | Owner: lsansonetti@…
Type: enhancement | Status: new
Priority: blocker | Milestone: MacRuby 0.7
Component: MacRuby | Keywords: block
-------------------------------+--------------------------------------------
The following (proposed) syntax should work:
{{{
open_panel = NSOpenPanel.openPanel
open_panel.beginSheetModalForWindow(@main_window,
completionHandler:lambda{|arg|
puts "Hello, open file and user arg is #{arg}"
}
)
}}}
Also, this should work:
{{{
def handler(arg)
puts "Hello, open file and user arg is #{arg}"
end
open_panel = NSOpenPanel.openPanel
open_panel.beginSheetModalForWindow(@main_window,
completionHandler:handler)
}}}
There may be a more elegant Rubyish way to do this, but I'm not seeing how
the proper selector syntax would be created. Here's what I mean:
{{{
open_panel = NSOpenPanel.openPanel
open_panel.beginSheetModalForWindow(@main_window) do |arg|
puts "Hello, open file and user arg is #{arg}"
end
}}}
But the last example gives no hint that the block selector should be
completionHandler:
--
Ticket URL: <http://www.macruby.org/trac/ticket/712>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list