Reputation: 564
How do you detect when a user clicks the green maximize or zoom (+) button on the NSWindow without using the NSWindowDidResizeNotification
?
The reason I don't want to use NSWindowDidResizeNotification
is because that is also triggered repeatedly as the user clicks and drags to manually resize the window. I have some code that I want to execute and it should only fire once when the user zooms or de-zooms the window using the green button in the top left-hand corner and not many times when manually resizing the window.
Upvotes: 5
Views: 3033
Reputation: 20396
@EagleOfToledo, based on your question and your comments on Todd Yandell's answer, I think you only need this delegate method:
Swift
optional func windowDidEndLiveResize(_ notification: NSNotification)
Objective-C
- (void)windowDidEndLiveResize:(NSNotification *)notification
This method will only be invoked once no matter you click the zoom button or resize manually.
Upvotes: 0
Reputation: 14696
These two window delegate methods may be useful:
- windowWillUseStandardFrame:defaultFrame:
- windowShouldZoom:toFrame:
You might also consider subclassing NSWindow and overriding the zoom:
method.
Upvotes: 11