How to receive notifications when moving Window by mouse?

廉价感情. 提交于 2019-12-19 09:46:27

问题


I tried -setFrame:display: and -windowDidMove: but they are not sent while moving window.


回答1:


If You want to track NSWindow live moving, it's not possible by default You’ll have to do it on your own. It's possible to get notification when NSWindow is started to drag (move) with NSWindowWillMoveNotification or ended dragging (moving) - NSWindowDidMoveNotification.

Take a look at these examples they can help You to solve live window moving problem:

1. Example:

Description: Very short category on NSWindow that makes windows post NSWindowDidMove notifications continuously during dragging (much like NSWindowDidResizeNotification behaves). Uses a secondary thread and behavior can be toggled.

Download link.

2. Example:

Project download link.




回答2:


You can register an observer for NSWindowDidMoveNotification.



来源:https://stackoverflow.com/questions/10495037/how-to-receive-notifications-when-moving-window-by-mouse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!