xBACP
xBACP

Reputation: 551

Does NSWindowController showWindow Trigger Embedded NSView setNeedsDisplay?

I have a window with a custom NSView. I use a NSWindowController to load it from NIB in code.

Question: If I send the showWindow message for the NSWindowController, will it also send the setNeedsDisplay message for the embedded custom NSView in the window's hierarchy?

Upvotes: 0

Views: 145

Answers (1)

Abhi Beckert
Abhi Beckert

Reputation: 33359

In general you only ever need to send [self setNeedsDisplay:YES] when a value used inside -drawRect is changed after the view appears for the first time. It should always be sent by self, other objects should never need to send a -setNeedsDisplay: message except to work around a bug or something.

Since showWindow is before the window is initially drawn to the screen, you do not usually need -setNeedsDisplay:, unless (again) you've found a bug.

If you open the menu item Xcode -> Open Developer Tool -> More Developer Tools... and search for "graphics", you can download a bundle of tools, one of which is Quartz Debug. Using this debugger, you can make the screen flash yellow whenever the screen is drawn to, and red whenever a screen draw simply re-draws whatever was already visible.

You can use this to find out what parts of the screen are being refreshed too frequently.

Upvotes: 1

Related Questions