Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Dedupe handling of mouse buttons in macos backend. #20778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 6 additions & 121 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -1885,127 +1885,12 @@ - (void)mouseDragged:(NSEvent *)event
PyGILState_Release(gstate);
}

- (void)rightMouseDown:(NSEvent *)event
{
int x, y;
int num = 3;
int dblclick = 0;
PyObject* result;
PyGILState_STATE gstate;
NSPoint location = [event locationInWindow];
location = [self convertPoint: location fromView: nil];
x = location.x * device_scale;
y = location.y * device_scale;
gstate = PyGILState_Ensure();
if ([event clickCount] == 2) {
dblclick = 1;
}
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
if(result)
Py_DECREF(result);
else
PyErr_Print();

PyGILState_Release(gstate);
}

- (void)rightMouseUp:(NSEvent *)event
{
int x, y;
int num = 3;
PyObject* result;
PyGILState_STATE gstate;
NSPoint location = [event locationInWindow];
location = [self convertPoint: location fromView: nil];
x = location.x * device_scale;
y = location.y * device_scale;
gstate = PyGILState_Ensure();
result = PyObject_CallMethod(canvas, "button_release_event", "iii", x, y, num);
if(result)
Py_DECREF(result);
else
PyErr_Print();

PyGILState_Release(gstate);
}

- (void)rightMouseDragged:(NSEvent *)event
{
int x, y;
NSPoint location = [event locationInWindow];
location = [self convertPoint: location fromView: nil];
x = location.x * device_scale;
y = location.y * device_scale;
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject* result = PyObject_CallMethod(canvas, "motion_notify_event", "ii", x, y);
if(result)
Py_DECREF(result);
else
PyErr_Print();

PyGILState_Release(gstate);
}

- (void)otherMouseDown:(NSEvent *)event
{
int x, y;
int num = 2;
int dblclick = 0;
PyObject* result;
PyGILState_STATE gstate;
NSPoint location = [event locationInWindow];
location = [self convertPoint: location fromView: nil];
x = location.x * device_scale;
y = location.y * device_scale;
gstate = PyGILState_Ensure();
if ([event clickCount] == 2) {
dblclick = 1;
}
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
if(result)
Py_DECREF(result);
else
PyErr_Print();

PyGILState_Release(gstate);
}

- (void)otherMouseUp:(NSEvent *)event
{
int x, y;
int num = 2;
PyObject* result;
PyGILState_STATE gstate;
NSPoint location = [event locationInWindow];
location = [self convertPoint: location fromView: nil];
x = location.x * device_scale;
y = location.y * device_scale;
gstate = PyGILState_Ensure();
result = PyObject_CallMethod(canvas, "button_release_event", "iii", x, y, num);
if(result)
Py_DECREF(result);
else
PyErr_Print();

PyGILState_Release(gstate);
}

- (void)otherMouseDragged:(NSEvent *)event
{
int x, y;
NSPoint location = [event locationInWindow];
location = [self convertPoint: location fromView: nil];
x = location.x * device_scale;
y = location.y * device_scale;
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject* result = PyObject_CallMethod(canvas, "motion_notify_event", "ii", x, y);
if(result)
Py_DECREF(result);
else
PyErr_Print();

PyGILState_Release(gstate);
}
- (void)rightMouseDown:(NSEvent *)event { [self mouseDown: event]; }
- (void)rightMouseUp:(NSEvent *)event { [self mouseUp: event]; }
- (void)rightMouseDragged:(NSEvent *)event { [self mouseDragged: event]; }
- (void)otherMouseDown:(NSEvent *)event { [self mouseDown: event]; }
- (void)otherMouseUp:(NSEvent *)event { [self mouseUp: event]; }
- (void)otherMouseDragged:(NSEvent *)event { [self mouseDragged: event]; }

- (void)setRubberband:(NSRect)rect
{
Expand Down