Skip to content

Commit 42886d7

Browse files
committed
Allowing mouse dragging with three-button mice.
svn path=/trunk/matplotlib/; revision=7627
1 parent fe4c4c9 commit 42886d7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/_macosx.m

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,10 @@ - (void)mouseDragged:(NSEvent*)event;
349349
- (void)mouseMoved:(NSEvent*)event;
350350
- (void)rightMouseDown:(NSEvent*)event;
351351
- (void)rightMouseUp:(NSEvent*)event;
352+
- (void)rightMouseDragged:(NSEvent*)event;
352353
- (void)otherMouseDown:(NSEvent*)event;
353354
- (void)otherMouseUp:(NSEvent*)event;
355+
- (void)otherMouseDragged:(NSEvent*)event;
354356
- (void)setRubberband:(NSRect)rect;
355357
- (void)removeRubberband;
356358
- (const char*)convertKeyEvent:(NSEvent*)event;
@@ -4744,6 +4746,23 @@ - (void)rightMouseUp:(NSEvent *)event
47444746
PyGILState_Release(gstate);
47454747
}
47464748

4749+
- (void)rightMouseDragged:(NSEvent *)event
4750+
{
4751+
int x, y;
4752+
NSPoint location = [event locationInWindow];
4753+
location = [self convertPoint: location fromView: nil];
4754+
x = location.x;
4755+
y = location.y;
4756+
PyGILState_STATE gstate = PyGILState_Ensure();
4757+
PyObject* result = PyObject_CallMethod(canvas, "motion_notify_event", "ii", x, y);
4758+
if(result)
4759+
Py_DECREF(result);
4760+
else
4761+
PyErr_Print();
4762+
4763+
PyGILState_Release(gstate);
4764+
}
4765+
47474766
- (void)otherMouseDown:(NSEvent *)event
47484767
{
47494768
int x, y;
@@ -4784,6 +4803,23 @@ - (void)otherMouseUp:(NSEvent *)event
47844803
PyGILState_Release(gstate);
47854804
}
47864805

4806+
- (void)otherMouseDragged:(NSEvent *)event
4807+
{
4808+
int x, y;
4809+
NSPoint location = [event locationInWindow];
4810+
location = [self convertPoint: location fromView: nil];
4811+
x = location.x;
4812+
y = location.y;
4813+
PyGILState_STATE gstate = PyGILState_Ensure();
4814+
PyObject* result = PyObject_CallMethod(canvas, "motion_notify_event", "ii", x, y);
4815+
if(result)
4816+
Py_DECREF(result);
4817+
else
4818+
PyErr_Print();
4819+
4820+
PyGILState_Release(gstate);
4821+
}
4822+
47874823
- (void)setRubberband:(NSRect)rect
47884824
{
47894825
if (!NSIsEmptyRect(rubberband)) [self setNeedsDisplayInRect: rubberband];

0 commit comments

Comments
 (0)