File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -391,9 +391,20 @@ static CGFloat _get_device_scale(CGContextRef cr)
391
391
static PyObject*
392
392
FigureCanvas_flush_events (FigureCanvas* self)
393
393
{
394
- // We need to allow the runloop to run very briefly
395
- // to allow the view to be displayed when used in a fast updating animation
396
- [[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.0 ]];
394
+ // We run the app, matching any events that are waiting in the queue
395
+ // to process, breaking out of the loop when no events remain and
396
+ // displaying the canvas if needed.
397
+ NSEvent *event;
398
+ while (true ) {
399
+ event = [NSApp nextEventMatchingMask: NSEventMaskAny
400
+ untilDate: [NSDate distantPast ]
401
+ inMode: NSDefaultRunLoopMode
402
+ dequeue: YES ];
403
+ if (!event) {
404
+ break ;
405
+ }
406
+ [NSApp sendEvent: event];
407
+ }
397
408
[self ->view displayIfNeeded ];
398
409
Py_RETURN_NONE;
399
410
}
You can’t perform that action at this time.
0 commit comments