Reputation: 1684
NSWindowDelegate
protocol has a windowDidDeminiaturize
callback, but no windowWillDeminiaturize
callback. I need to catch the moment when the window is starting to deminiaturize and make changes to it before the user sees the changes applied.
I can't do the changes in windowDidMiniaturize
because I need to show another window; if I do it in windowDidMiniaturize
, this other window will appear as soon as the first one has miniaturized.
Any ideas?
Upvotes: 2
Views: 561
Reputation: 17898
Edit: I'm leaving this answer here, but it totally does not work reliably, see my comment below.
You could subclass NSWindow and override deminiaturize:
.
@interface MyWindow : NSWindow
@end
@implementation MyWindow
- (void) deminiaturize:(id)sender
{
NSLog( @"window about to deminiaturize!" );
[super deminiaturize:sender];
}
@end
Probably you want the window delegate to take some action when this happens, not the window, so you could do something like this:
- (void) deminiaturize:(id)sender
{
id<NSWindowDelegate> delegate = [self delegate];
if( [delegate respondsToSelector:@selector(windowWillDeminiaturize)] ) {
[delegate performSelector:@selector(windowWillDeminiaturize)];
}
[super deminiaturize:sender];
}
Upvotes: 1