I am writing an application which must know when any window is resized or moved. I have looked at notifications but it seems it does not do what I expected.
Do you have any idea how I can achieve this?
macOS Catalina or laterHold your pointer over the full-screen button in the upper-left corner of a window. Or click and hold the button. Choose ”Tile Window to Left of Screen” or ”Tile Window to Right of Screen” from the menu. The window then fills that side of the screen.
Finally, another option is to grab any portion of the window you can and hold down OPTION+SHIFT keys and drag, which will resize the window in any direction.
Give your window a delegate. The NSWindowDelegate protocol has windowWillResize:toSize:
and windowWillMove:
methods.
Given your response to Carl's answer, I'd suggest the Accessibility API, which can give you access (and I believe frame change notifications) for all windows, not just your app's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With