Re: NSWindow's setBackgroundColor: method problem
Re: NSWindow's setBackgroundColor: method problem
- Subject: Re: NSWindow's setBackgroundColor: method problem
- From: "Mark Munz" <email@hidden>
- Date: Mon, 3 Jul 2006 19:07:14 -0700
It sounds like the Window hasn't been told that it needs to redraw itself.
Theoretically, you should just call setNeedsDisplay on the contentView
([[docWindow contentView] setNeedsDisplay:YES];),
but if you have a toolbar, it will not invalidate some areas, leaving
a bit of a mess.
And there doesn't appear to be a simple way to get the toolbar view to
invalidate it.
So, instead, I call [docWindow display]; to force the entire window to redraw.
Mark Munz
On 7/3/06, Andrew Madsen <email@hidden> wrote:
I'm seeing something I don't understand with the setBackgroundColor:
method of NSWindow. I'm writing a document-based app. In the
windowControllerDidLoadNib: method of MyDocument.m I set the
background color of the window to the color I want and everything is
fine. I want it to switch to another color when it's not the key
window. So, I register MyDocument for the
NSWindowDidResignKeyNotification and NSWindowDidBecomeKeyNotification
in order to change the window background color when the window
switches between being key and not key. In the the methods
registered with the notification center, I have exactly one line (in
each):
[docWindow setBackgroundColor: [NSColor redColor]]; //For when the
window is key
[docWindow setBackgroundColor: [NSColor greenColor]]; //For when the
window is not key
(I'm not really planning on using red and green, they just make it
really easy to see what's going on.)
What I don't understand is that the window comes up red just like I'd
expect when I open the app or create a new document. However, when I
click on another window, thus making the document window resign its
key status, only a small portion of the window turns green. The area
around whatever element of the window (search field, text field, etc)
is active turns green, but the rest of the window stays red. I can't
figure out why the [docWindow setBackgroundColor:] method call
doesn't seem to affect the whole window. Can anyone shed some light
on this?
Thanks!
Andrew Madsen
_______________________________________________
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
_______________________________________________
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