Re: needsDisplay and subviews
Re: needsDisplay and subviews
- Subject: Re: needsDisplay and subviews
- From: corbin dunn <email@hidden>
- Date: Thu, 09 Mar 2017 10:32:48 -0800
> On Mar 8, 2017, at 8:46 AM, Jeremy Hughes <email@hidden> wrote:
>
> If needsDisplay is set to true for an NSView, does that also cause subviews to be redrawn?
>
> I’ve seen conflicting statements about this, but haven’t found anything in Apple’s documentation.
Just to be clear: if you want a view to be redrawn you should call setNeedsDisplay on that view. That’s really the bottom line. There are some cases where AppKit will redraw subviews when a parent view is invalidated, but you should not depend on this!
I also don’t recommend things like this:
> override var needsDisplay: Bool
> {
> willSet
> {
> for view in subviews
> {
> view.needsDisplay = newValue
> }
> }
Instead, it is better if your subviews invalidate themselves when their state changes.
corbin
_______________________________________________
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