Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Notification when a view goes offscreen?



On Jan 27, 2004, at 8:16 AM, Nicholas Francis wrote:
Hi guys...

In our app, I'm pulling complete view hierarchies off-screen, and replacing them with something else. Is there a way for a view to get notified when it goes offscreen (like in its parent being -removeFromSuperview)?

NSView provides stub methods that get invoked when a view's window or superview changes:

- (void)viewWillMoveToWindow:(NSWindow *)newWindow;
- (void)viewDidMoveToWindow;
- (void)viewWillMoveToSuperview:(NSView *)newSuperview;
- (void)viewDidMoveToSuperview;

You can override these in a subclass to receive notice of such occurrences.

This covers views "going offscreen" in the way that I gather you are concerned with here (due to swapping of views out of and into a window via -removeFromSuperview and -addSubview: operations). If you were interested in other ways that a view can "go offscreen" (e.g. due to its window being closed or moved to another screen), you'd also want to take a look at the notifications declared in NSWindow.h. For the NSView -setHidden: API introduced in Panther, there is currently no notification mechanism, but one could simply override -setHidden: to invoke super's implementation and then perform whatever actions are needed:

- (void)setHidden:(BOOL)hiding {
[super setHidden:hiding];
// Now do whatever we need to in response to this change...
}

Hope this helps.

Troy Stephens
Cocoa frameworks
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Notification when a view goes offscreen? (From: Nicholas Francis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.