Question

I'm showing a popup menu when clicking a button. The problem is that, when that menu is open, timers no longer work:

To show the menu:

[_menu popUpMenuPositioningItem:nil atLocation:point inView:nil];

My timer (called before the popup) is no longer sending messages after the button is clicked.

[NSTimer scheduledTimerWithTimeInterval:0.50
                                 target:self
                               selector:@selector(myMethod:)
                               userInfo:nil
                                repeats:YES];

Have also tried [NSEvent addGlobalMonitorForEventsMatchingMask..] and even CGEventTapCreate. Nothing gets called.

How do I make the popup not-blocking / modal? I know this is possible, I've seen another app do it. Thanks for any ideas.

Était-ce utile?

La solution

The problem may be that the NSTimer is not running on the right mode. Try grabbing the current run loop by creating a NSRunLoop object. Then add your timer to the NSModalPanelRunLoopMode using the method addTimer:forMode: (in the run loop object you just created). You can read more about it in the Apple Docs here: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/Reference/Reference.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top