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: Just a single didBecomeMain/didResignMain event being fired



From: Thilo Ettelt <email@hidden>

I have a problem with a NSBorderless (custom shaped) window. In my controller, which is the window's delegate, i've put an NSLog between the brackets of '-windowDidResignMain' and '-windowDidBecomeMain'. But the NSLogs are doing their job just once - when the window has been openend and when i switched to a different window. When I switch back: no more windowDidBecomeMain event. And then again: no windowDidResignMain event.

I have not read any documentation lately and I'm too sleepy to go read some now, but I'm guessing that if your controller is logging during windowDidBecomeMain that your window did become main.

My first thought was that you might be confused by keywindow/mainwindow differences, but then I re-read your message and you clearly say that after windowDidBecomeMain logs that windowDidResignMain logs (does that mean that your window did resign main?).

I can only think of two reasons for not getting a second windowDidBecomeMain: your window is not becoming main, or your controller is no longer listening for this notification. Neither seems likely given that your window did resign main and that controllers (especially when nib allocated) don't usually disappear without notice.

So, I'm totally lost and can only recommend a few more logs. If you already have a window subclass, it would be easy to log during:
- (void)becomeMainWindow
- (void)becomeKeyWindow
- (BOOL)canBecomeMainWindow
Which will verify that your window is not actually becoming main without sending a notification to your controller. I can't think of why your controller would stop listening for this notification, so I doubt this is your problem. If this kind of trouble shooting makes you feel like progress is being made, you may also want to log during your controller's dealloc method (here I'm assuming that you remove this controller from its thread's notification center during dealloc).

I would also do something like this:
- (void) resignMainWindow
{
[super resignMainWindow];
NSLog(@"self 0x%.6x is main %d", self, [self isMainWindow]);
}
Which would verify that after didResignMainWindow that you are no longer main. But, I ask myself if this is even possble and can only answer that I don't think so. So why did I suggest it? just silly really, but I can't think of any reason why you only get one windowDidBecomeMain notification.


-jim


P.S. there is probably a better way to print self than 0x%.6x, but I don't know what it is.
_______________________________________________
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: 
 >Re: Just a single didBecomeMain/didResignMain event being fired (From: "Kenneth C. Dyke" <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.