如何在鼠标移动窗口时接收通知? [英] How to receive notifications when moving Window by mouse?

查看:440
本文介绍了如何在鼠标移动窗口时接收通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了 -setFrame:display: -windowDidMove:,但是它们不会在移动窗口时发送。 / p>

解决方案

如果您要跟踪 NSWindow 默认你必须自己做。当 NSWindow 开始拖动(移动) NSWindowWillMoveNotification 或结束拖动(移动) code> NSWindowDidMoveNotification 。



看看这些例子,他们可以帮助你解决实时窗口移动问题:



1。示例:



说明:NSWindow NSWindowDidMove在拖动期间不断地通知(很像
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.

Download link.

2. Example:

Project download link.

这篇关于如何在鼠标移动窗口时接收通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆