Re: NSWindowController troubles.
Re: NSWindowController troubles.
- Subject: Re: NSWindowController troubles.
- From: Derrick Bass <email@hidden>
- Date: Wed, 14 Dec 2005 00:17:35 -0600
On Dec 13, 2005, at 10:02 PM, Brandon Meyer wrote:
Hi all,
I'm rather new to this whole Cocoa thing, so any help or insights
to this issue would be greatly appreciated.
Okay, I'm not much further along, so I hope the gurus will correct
any mistakes I make in my response.
I'm having trouble understanding what's actually going on here... I
have an app delegate that handles opening new windows via a
NSWindowController subclass. It also takes care of keeping track
of the front-most window by way of NSNotificationCenter then
setting a local variable of NSWindowController subclass type that
corresponds to the
Do mean an instance variable in your app delegate? NSApplication
already keeps track of this. See mainWindow and keyWindow. If you
need the controller and not the window itself, take a look at -
[NSWindow windowController].
windowController. I am sending UI actions through the delegate to
the front-most window's controller. When I open a
new window, all of the UI actions work correctly until that window
loses focus and then regains focus. I get a flash of the menu to
tell me that it recognized my event, but the window shows no signs
of the event being passed to it.
I'm pretty confused by all this; maybe I'm misinterpreting what you
are doing. But anyway, Cocoa keeps track of which window is in front
and which is key (and therefore which one receives events) all by
itself. Unless you are doing something pretty complicated, you
shouldn't need to worry about passing UI actions to your windows. It
will Just Work (TM). You use notifications if, for some reason, you
need to know exactly when the main window changes (e.g. for updating
an inspector window).
I should note that my NSWindowController subclass refers to it's
window via an outlet named 'theWindow'. If I change that outlet's
name to 'window', the events seem to pass to the window, but my
custom NSView doesn't display properly.
NSWindowController already has an outlet called "window". There's no
need to create a new one in a subclass. That may be the problem; by
connecting your window to some other outlet, you are confusing Cocoa.
The things you put in a window controller subclass are custom things
that a window has to do. For example, if it needs to do something
when you push a button, you'd put an action like "doSomethingCool:"
into the window controller subclass connect the button to that action.
Derrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden