如何在鼠标移动窗口时接收通知? [英] How to receive notifications when moving Window by mouse?
问题描述
我尝试了 -setFrame:display:
和 -windowDidMove:
,但是它们不会在移动窗口时发送。 / p>
如果您要跟踪 NSWindow
默认你必须自己做。当 NSWindow
开始拖动(移动) NSWindowWillMoveNotification
或结束拖动(移动) code> NSWindowDidMoveNotification 。
看看这些例子,他们可以帮助你解决实时窗口移动问题:
1。示例:
NSWindowDidResizeNotification行为)。使用辅助线程和
行为可以切换。
下载链接。
2。示例:
I tried -setFrame:display:
and -windowDidMove:
but they are not sent while moving window.
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.
2. Example:
这篇关于如何在鼠标移动窗口时接收通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!