Skip to content

Commit e25abbe

Browse files
committed
Implement close_event in the Mac OS X native backend.
svn path=/trunk/matplotlib/; revision=8762
1 parent 72b5ff6 commit e25abbe

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/_macosx.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ - (void)drawRect:(NSRect)rect;
346346
- (void)windowDidResize:(NSNotification*)notification;
347347
- (View*)initWithFrame:(NSRect)rect;
348348
- (void)setCanvas: (PyObject*)newCanvas;
349+
- (void)windowWillClose:(NSNotification*)notification;
349350
- (BOOL)windowShouldClose:(NSNotification*)notification;
350351
- (BOOL)isFlipped;
351352
- (void)mouseEntered:(NSEvent*)event;
@@ -4935,6 +4936,20 @@ - (void)windowDidResize: (NSNotification*)notification
49354936
[self setNeedsDisplay: YES];
49364937
}
49374938

4939+
- (void)windowWillClose:(NSNotification*)notification
4940+
{
4941+
PyGILState_STATE gstate;
4942+
PyObject* result;
4943+
4944+
gstate = PyGILState_Ensure();
4945+
result = PyObject_CallMethod(canvas, "close_event", "");
4946+
if(result)
4947+
Py_DECREF(result);
4948+
else
4949+
PyErr_Print();
4950+
PyGILState_Release(gstate);
4951+
}
4952+
49384953
- (BOOL)windowShouldClose:(NSNotification*)notification
49394954
{
49404955
NSWindow* window = [self window];

0 commit comments

Comments
 (0)