From 72ae85dd61608315d54cb417177d7850472c1989 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Wed, 8 Oct 2003 15:51:40 +0000 Subject: [PATCH] Implement Pending and Dispatch git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24125 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/cocoa/evtloop.mm | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/cocoa/evtloop.mm b/src/cocoa/evtloop.mm index bd1611587b..d7870baa9a 100644 --- a/src/cocoa/evtloop.mm +++ b/src/cocoa/evtloop.mm @@ -17,6 +17,8 @@ #include "wx/evtloop.h" #import +#import +#import // ======================================================================== // wxEventLoopImpl @@ -95,12 +97,30 @@ void wxEventLoop::Exit(int rc) bool wxEventLoop::Pending() const { - return 0; + // a pointer to the event is returned if there is one, or nil if not + return [[NSApplication sharedApplication] + nextEventMatchingMask: NSAnyEventMask + untilDate: nil /* Equivalent to [NSDate distantPast] */ + inMode: NSDefaultRunLoopMode + dequeue: NO]; } bool wxEventLoop::Dispatch() { + // This check is required by wxGTK but probably not really for wxCocoa + // Keep it here to encourage developers to write cross-platform code wxCHECK_MSG( IsRunning(), false, _T("can't call Dispatch() if not running") ); + NSApplication *cocoaApp = [NSApplication sharedApplication]; + // Block to retrieve an event then send it + if(NSEvent *event = [cocoaApp + nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate distantFuture] + inMode:NSDefaultRunLoopMode + dequeue: YES]) + { + [cocoaApp sendEvent: event]; + return true; + } return false; } -- 2.45.2