RE: I want a window's file owner that's not a NSWindowController
RE: I want a window's file owner that's not a NSWindowController
- Subject: RE: I want a window's file owner that's not a NSWindowController
- From: Shawn Bakhtiar <email@hidden>
- Date: Tue, 28 Sep 2010 13:47:08 -0400
- Importance: Normal
NSWindowController is for when you want to have multiple windows of the same class (derived from NSWindow), but have different set of callbacks, in different Window controllers that you can attach to each identical NSWindow, in essence giving you a window class, that can have a different set of callback functions.
Question, why not just derive the camera class from NSWindow? There is no programmatic need for NSWindowController, as an NSWindow is also an NSResponder (can take all input).
> From: email@hidden
> Date: Tue, 28 Sep 2010 18:41:40 +0100
> To: email@hidden
> Subject: I want a window's file owner that's not a NSWindowController
>
> I am trying to understand the right way of dealing with a "settings" window in my application. I have a "Camera" object that wraps a Firewire video camera. I would like to bring up an NSPanel that enables various settings of the camera to be modified. I do not need to override any particular behaviours of NSWindowController, and it seems to me that logically my Camera object should not need to inherit from NSWindowController (the window business is a bit of a distraction from the main purpose of the camera class, which is handling received frames - and in future I may want more than one such camera-related window).
>
> What I thought I could do when I want to bring the settings window up is as follows (from within my Camera class):
> if (settingsWindowController == NULL)
> settingsWindowController = [[NSWindowController alloc] initWithWindowNibName:(NSString *)@"Camera Settings" owner:self];
> [settingsWindowController showWindow:self];
> (where settingsWindowController is an instance variable of type NSWindowController). In the nib file I have set the File's Owner proxy to type Camera, and the bindings I have set up for the window all work correctly. However [settingsWindowController window] returns nil, and this causes various problems. Clearly I am doing something wrong.
>
> Alternatively I can set the File's Owner to type NSWindowController (and not specify an owner in my call to initWithWindowNibName). If I do this then the window controller is correctly linked to the window (I link up the appropriate outlet in IB), but the bindings don't work.
>
> I can't work out whether there is a way I can get my (instance variable-based) window controller to work AND bind to the Camera object. I feel this would be the tidiest way of doing things (it doesn't make sense to me for Camera to inherit from NSWindowController). Is there something extra I need to do to make this work, or am I just approaching all this in the wrong way?
>
> I have tried adding an NSWindowController object in the nib (with File's Owner still Camera). I can wire that up to the window, but I suspect that's not doing anything because I am allocating my own NSWindowController object in the code I listed earlier. I wonder if adding the NSWindowController object is the way forwards - but if so, how to I go about loading the controller from the nib as well as the window itself? I suspect from various other confused postings in the archives that initWindowWindowNibName:owner may not be the right thing for me to use here.
>
> Hopefully this makes sense - thanks for any suggestions...
> Jonny_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden