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

Skip to content

Commit 2c51a33

Browse files
committed
[UNTESTED] double click support added to macosx backend. Note that this
code has not even been compiled as of yet.
1 parent a2655ec commit 2c51a33

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/_macosx.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5100,6 +5100,7 @@ - (void)mouseDown:(NSEvent *)event
51005100
{
51015101
int x, y;
51025102
int num;
5103+
int dblclick = 0;
51035104
PyObject* result;
51045105
PyGILState_STATE gstate;
51055106
NSPoint location = [event locationInWindow];
@@ -5127,8 +5128,11 @@ - (void)mouseDown:(NSEvent *)event
51275128
case NSRightMouseDown: num = 3; break;
51285129
default: return; /* Unknown mouse event */
51295130
}
5131+
if ([event clickCount] == 2]) {
5132+
dblclick = 1;
5133+
}
51305134
gstate = PyGILState_Ensure();
5131-
result = PyObject_CallMethod(canvas, "button_press_event", "iii", x, y, num);
5135+
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
51325136
if(result)
51335137
Py_DECREF(result);
51345138
else
@@ -5205,14 +5209,18 @@ - (void)rightMouseDown:(NSEvent *)event
52055209
{
52065210
int x, y;
52075211
int num = 3;
5212+
int dblclick = 0;
52085213
PyObject* result;
52095214
PyGILState_STATE gstate;
52105215
NSPoint location = [event locationInWindow];
52115216
location = [self convertPoint: location fromView: nil];
52125217
x = location.x;
52135218
y = location.y;
52145219
gstate = PyGILState_Ensure();
5215-
result = PyObject_CallMethod(canvas, "button_press_event", "iii", x, y, num);
5220+
if ([event clickCount] == 2]) {
5221+
dblclick = 1;
5222+
}
5223+
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
52165224
if(result)
52175225
Py_DECREF(result);
52185226
else
@@ -5262,14 +5270,18 @@ - (void)otherMouseDown:(NSEvent *)event
52625270
{
52635271
int x, y;
52645272
int num = 2;
5273+
int dblclick = 0;
52655274
PyObject* result;
52665275
PyGILState_STATE gstate;
52675276
NSPoint location = [event locationInWindow];
52685277
location = [self convertPoint: location fromView: nil];
52695278
x = location.x;
52705279
y = location.y;
52715280
gstate = PyGILState_Ensure();
5272-
result = PyObject_CallMethod(canvas, "button_press_event", "iii", x, y, num);
5281+
if ([event clickCount] == 2]) {
5282+
dblclick = 1;
5283+
}
5284+
result = PyObject_CallMethod(canvas, "button_press_event", "iiii", x, y, num, dblclick);
52735285
if(result)
52745286
Py_DECREF(result);
52755287
else

0 commit comments

Comments
 (0)