RubyCocoa and sheets

I’m using RubyCocoa, translating an Objective-C checkbook application to
Ruby. My problem comes when I try to close a modal sheet. I open it from
within a subclass of OSX::NSWindowController. The window() method returns
the NSPanel that is being used as a sheet. Here’s the code I use to open
it:

    NSApp().beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(window(), @parentWindow, self, nil, nil)
    NSApp().runModalForWindow(window())

I try to close the sheet using this code, which is called when the user
clicks either “Ok” or “Cancel”:

    NSApp().endSheet(window())
    window().orderOut(nil)

The problem is, I get a stack dump on the “endSheet” line. I think the dump
is saying that the window() argument is not legitimiate. My confusion
arises because this same code works in Objective-C.

    [NSApp endSheet:window];
    [window orderOut:nil];

Here’s the stack dump I see. Any suggestions?

2003-03-30 08:28:05.683 RubyCheckbook[12564] *** -[FindController ]:
selector not recognized
/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17:in
ocm_send': NSApplication#endSheet: - NSInvalidArgumentException - *** -[FindController ]: selector not recognized (OSX::OCException) from /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17:inmethod_missing’
from
/Users/jimm/projects/RubyCheckbook/build/RubyCheckbook.app/Contents/Resources/FindController.rb:55:in doneFinding' from /Users/jimm/projects/RubyCheckbook/build/RubyCheckbook.app/Contents/Resources/FindController.rb:51:inperformFind’
from
/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17:in ocm_send' from /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17:inmethod_missing’
from
/Users/jimm/projects/RubyCheckbook/build/RubyCheckbook.app/Contents/Resources/FindController.rb:19:in openFindPanel' from /Users/jimm/projects/RubyCheckbook/build/RubyCheckbook.app/Contents/Resources/rb_main.rb:19:inNSApplicationMain’
from
/Users/jimm/projects/RubyCheckbook/build/RubyCheckbook.app/Contents/Resources/rb_main.rb:19

RubyCheckbook has exited with status 1.

···


Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“This looks like a job for emergency pants!” – Torg, www.sluggy.com

    NSApp().beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(window(), @parentWindow, self, nil, nil)
    NSApp().runModalForWindow(window())

Does this article help you?

http://www.oreillynet.com/cs/user/view/cs_msg/5341

···

From: Jim Menard jimm@io.com
Subject: RubyCocoa and sheets
Date: Sun, 30 Mar 2003 22:49:32 +0900


shirai@korinkan.co.jp

Shirai,Kaoru
Korinkan Ltd.