单击按钮时,我会显示一个弹出菜单。问题是,当该菜单打开时,计时器不再起作用:
显示菜单:
[_menu popUpMenuPositioningItem:nil atLocation:point inView:nil];
单击按钮后,我的计时器(在弹出窗口之前调用)不再发送消息。
[NSTimer scheduledTimerWithTimeInterval:0.50
target:self
selector:@selector(myMethod:)
userInfo:nil
repeats:YES];
还尝试了[NSEvent addGlobalMonitorForEventsMatchingMask ..]甚至CGEventTapCreate。什么都没有被调用。
如何让popup not-blocking / modal?我知道这是可能的,我见过另一个应用程序。谢谢你的任何想法。
答案 0 :(得分:1)
问题可能是NSTimer没有在正确的模式下运行。尝试通过创建NSRunLoop对象来抓取当前的运行循环。然后使用addTimer:forMode :(在刚刚创建的运行循环对象中)方法将计时器添加到NSModalPanelRunLoopMode。您可以在Apple文档中详细了解它:https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/Reference/Reference.html