Focus window from second XIB
Hi For the preferences, I've created a second XIB. However, when the corresponding controller is instantiated, the window does appear but does not gain focus. Any idea what I'm doing wrong here? preferences_controller.rb: class PreferencesController < NSWindowController def windowNibName() return "Preferences" end end application_controller.rb: def menu_preferences(sender) preferences = PreferencesController.new end The Preferences.xib has a delegate which points to PreferencesController which has it's window outlet point to the window. The File's Owner is also set to the PreferencesController. Thanks for your help! -sven
Hi Sven, Creating a window wont necessarily make it the Key or Main window. What I tend to do is always disable the "visible at launch" checkbox inside interface builder and do something like def menu_preferences(sender) preferences = PreferencesController.new preferences.center() preferences.makeKeyAndOrderFront(self) end -Robert On Mar 2, 2011, at 8:11 AM, Sven Schwyn wrote:
Hi
For the preferences, I've created a second XIB. However, when the corresponding controller is instantiated, the window does appear but does not gain focus. Any idea what I'm doing wrong here?
preferences_controller.rb: class PreferencesController < NSWindowController def windowNibName() return "Preferences" end end
application_controller.rb: def menu_preferences(sender) preferences = PreferencesController.new end
The Preferences.xib has a delegate which points to PreferencesController which has it's window outlet point to the window. The File's Owner is also set to the PreferencesController.
Thanks for your help! -sven
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Franco Thanks for the quick reply. However, I get this if I try your hint: undefined method `center' for #<PreferencesController... I seem to be missing something else, too. Cheers, -sven
Hi Sven, Actually it's preferences.window.center() preferences.window.makeKeyAndOrderFront(self) Sorry! -Robert On Mar 2, 2011, at 8:19 AM, Sven Schwyn wrote:
Hi Franco
Thanks for the quick reply. However, I get this if I try your hint:
undefined method `center' for #<PreferencesController...
I seem to be missing something else, too.
Cheers, -sven
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (2)
-
Robert Payne
-
Sven Schwyn