views:

86

answers:

1

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.

+3  A: 

These two window delegate methods may be useful:

- windowWillUseStandardFrame:defaultFrame:
- windowShouldZoom:toFrame:

You might also consider subclassing NSWindow and overriding the zoom: method.

Todd Yandell
That's it! My poor man's workaround was to create a BOOL flag "windowIsResizing" and set it to "YES" on the NSWindowWillStartLiveResizeNotification and back to "NO" on the NSWindowWillEndLiveResizeNotification. Then in the WindowDidResize notification I did "if (!windowIsResizing) ... " and when the window was being manually resized this would prevent the multiple firing of the code that I wanted executed only once, it would only fire when the user pressed the zoom button. But this is much better, thanks!
EagleOfToledo