Ticket #712 (closed enhancement: fixed)
Feature Request: Add Support for C-Level Blocks
| Reported by: | cwdinfo@… | Owned by: | lsansonetti@… |
|---|---|---|---|
| Priority: | blocker | Milestone: | MacRuby 0.7 |
| Component: | MacRuby | Keywords: | block |
| Cc: | mike@… |
Description
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:
Change History
Note: See
TracTickets for help on using
tickets.

