How to receive notifications when moving a window with the mouse?

I tried -setFrame:display: and -windowDidMove: but they are not dispatched while the window is being moved.

+3
source share
2 answers

If you want to track the movement of NSWindow live, this is not possible by default. Youll have to do it yourself. You can be notified when NSWindow starts to drag (move) using NSWindowWillMoveNotification or end the drag (move) - NSWindowDidMoveNotification .

Take a look at these examples, they will help you solve the problem of moving in real time:

1. Example:

Description: A very short category in NSWindow that makes Windows Post NSWindowDidMove notify continuously during drag and drop (just like NSWindowDidResizeNotification behaves). Uses a secondary stream and behavior can be switched.

Download link .

2. Example:

Link to download the project .

+4
source

You can register an observer for NSWindowDidMoveNotification .

-2
source

Source: https://habr.com/ru/post/1469493/


All Articles