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