Reputation:
Is there a proper way to determine if a NSView
is actually drawn in the current view hierarchy or not, considering cases like:
The -isHidden
and -isHiddenOrHasHiddenAncestor
are unfortunately not set when e.g. a view disappears because a tab view switches to another tab.
The reason for this is that I have an attached child window and I would like to be able to hide it as well when the view that it is attached to is not drawn.
Upvotes: 4
Views: 1547
Reputation:
I have found a trick to tell if it is visible, but it requires subclassing. It works by toggling an ivar on 2 events.
- (void)discardCursorRects {
isDrawn_ = NO;
[super discardCursorRects];
}
- (void)resetCursorRects {
isDrawn_ = YES;
[super resetCursorRects];
}
Upvotes: 3
Reputation: 61228
Whether (or when) it's drawn is supposed to be "none of your business" and really have nothing to do with whether or not it's on-screen. Use NSView's -viewDidMoveToSuperview or -viewDidMoveToWindow to manage this.
Upvotes: 0