File tree 2 files changed +43
-0
lines changed
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,46 @@ void clickMouse(MMMouseButton button)
124
124
toggleMouse (false, button );
125
125
}
126
126
127
+ void doubleClick (MMMouseButton button )
128
+ {
129
+
130
+ #if defined(IS_MACOSX )
131
+
132
+ /* Double click for Mac. */
133
+ const CGPoint currentPos = CGPointFromMMPoint (getMousePos ());
134
+ const CGEventType mouseTypeDown = MMMouseToCGEventType (true, button );
135
+ const CGEventType mouseTypeUP = MMMouseToCGEventType (false, button );
136
+
137
+ CGEventRef event = CGEventCreateMouseEvent (NULL , mouseTypeDown , currentPos , kCGMouseButtonLeft );
138
+
139
+ /* Set event to double click. */
140
+ CGEventSetIntegerValueField (event , kCGMouseEventClickState , 2 );
141
+
142
+ CGEventPost (kCGHIDEventTap , event );
143
+
144
+ CGEventSetType (event , mouseTypeUP );
145
+ CGEventPost (kCGHIDEventTap , event );
146
+
147
+ CFRelease (event );
148
+
149
+ #elif defined(IS_WINDOWS )
150
+
151
+ /* Double click for Windows. */
152
+ clickMouse (button );
153
+ /* TODO: Use GetDoubleClickTime to retrieve the current double click time. */
154
+ microsleep (500 );
155
+ clickMouse (button );
156
+
157
+ #else
158
+
159
+ /* Double click for everything else. */
160
+ clickMouse (button );
161
+ microsleep (500 );
162
+ clickMouse (button );
163
+
164
+ #endif
165
+ }
166
+
127
167
/*
128
168
* A crude, fast hypot() approximation to get around the fact that hypot() is
129
169
* not a standard ANSI C function.
Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ void toggleMouse(bool down, MMMouseButton button);
73
73
/* Clicks the mouse with the given button in the current position. */
74
74
void clickMouse (MMMouseButton button );
75
75
76
+ /* Double clicks the mouse with the given button. */
77
+ void doubleClick (MMMouseButton button );
78
+
76
79
#endif /* MOUSE_H */
77
80
78
81
#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments