NSRunLoop冻结与NSTimer和任何输入 [英] NSRunLoop freezes with NSTimer and any input

查看:104
本文介绍了NSRunLoop冻结与NSTimer和任何输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,当我按下任何控件(点击并按住),NSTimer在我的应用程序冻结,不会发射,直到我释放鼠标按钮。它只是不会触发,而我有鼠标按下。这是很好的短期,但它也冻结,如果我有一个弹出菜单打开或组合框下降。

For some reason when I push down (click and hold) on any control, the NSTimer in my App freezes and does not fire until I release the mouse button. It simply does not fire while I have the mouse pressed. This is fine for short periods, but it also freezes if I have a popup menu open, or a combobox dropped down.

我不知道是否有东西错过了,但似乎这是不正确的行为。

I'm not sure if there is something I missed, but it seems like this is incorrect behavior.

我想能够点击NSPopUpButtonCell的向下箭头(甚至点击并按住NSTableView)整个NSTimer冻结(重新绘制NSView)。

I want to be able to click the down arrow of an NSPopUpButtonCell (or even click and hold an NSTableView) without the entire NSTimer freezing (which redraws an NSView).

任何意见/建议将不胜感激。

Any comments / suggestions would be appreciated.

NSTimer被添加到具有NSDefaultRunLoopMode模式的currentRunLoop。

The NSTimer is added to the currentRunLoop with mode NSDefaultRunLoopMode.

推荐答案

当鼠标关闭时,运行循环位于 NSEventTrackingRunLoopMode 。因此,在runloop返回到适当的模式之前,不会处理在EventTracking事件队列中收到的任何事件。

While the mouse is down, the run loop is in the NSEventTrackingRunLoopMode. Therefore, any event that's not received onto the EventTracking event queue won't be serviced until the runloop returns to the appropriate mode.

这是为两种模式(默认和事件跟踪)添加定时器到runloop。

The way around this is to add the timer to the runloop for both modes (default and event tracking).

这篇关于NSRunLoop冻结与NSTimer和任何输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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