X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b503b036c117287b0be2c9383a12a45680d5c81b..64374d1b0628da9aa157a31d63b4edfb03c98adb:/src/osx/cocoa/evtloop.mm diff --git a/src/osx/cocoa/evtloop.mm b/src/osx/cocoa/evtloop.mm index a8a8c561d7..1d607f9eaf 100644 --- a/src/osx/cocoa/evtloop.mm +++ b/src/osx/cocoa/evtloop.mm @@ -50,6 +50,7 @@ void wxGUIEventLoop::WakeUp() bool wxGUIEventLoop::Pending() const { + wxMacAutoreleasePool autoreleasepool; // a pointer to the event is returned if there is one, or nil if not return [[NSApplication sharedApplication] nextEventMatchingMask: NSAnyEventMask @@ -91,3 +92,20 @@ bool wxGUIEventLoop::Dispatch() return true; } + +int wxGUIEventLoop::DispatchTimeout(unsigned long timeout) +{ + wxMacAutoreleasePool autoreleasepool; + + NSEvent *event = [NSApp + nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate dateWithTimeIntervalSinceNow: timeout/1000] + inMode:NSDefaultRunLoopMode + dequeue: YES]; + if ( !event ) + return -1; + + [NSApp sendEvent: event]; + + return true; +}