My Setup
- XCode 4.3.2
- MacRuby 0.12 (ruby 1.9.2) [universal-darwin10.0, x86_64]
- Latest nightly as of 4 Jun, 2012
- OS 10.7.3
Goal
Have a window with some controls in a separate XIB from MainMenu.xib and be able to open that window programmatically. I do not want it to open at launch.
Attempts
- I made a new xib (Woot.xib) and created a window in it
I made a new Ruby class
class WootController < NSWindowController attr_accessor :window def windowNibName return 'Woot' end end
- I tried to set the class of File's Owner in the Woot.xib to be WootController, but found that it will not if
< NSWindowController
is in my class definition. If I remove the< NSWindowController
from the class definition, then the outlets populate and I can link the window in XIB to the window outlet in my class. From inside my AppDelegate's
applicationDidFinishLaunching
method, I've triedAttempt
newWind = WootController.new puts newWind #outputs "#<AddCredentialsDialog:0x400191180>" newWind.window().makeKeyAndOrderFront(self) # results in no method error for nil
Attempt 2
newWind = WootController.initWithWindowNibName 'AddWindow' puts newWind #outputs "#<AddCredentialsDialog:0x400191180>" newWind.window().makeKeyAndOrderFront(self) # results in no method error for nil
Questions
- Why don't either of my attempts work? I've ready just about everything I can find on macruby and using NSWindowController.
- Why can't I link my class
WootController
if I have it inheriting fromNSWindowController
- Is there a different way to do this other than putting it all in MainMenu.xib?