Skip to content

Commit 2fc100a

Browse files
committed
Added right/middle click support, closes #6.
1 parent e981548 commit 2fc100a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/robotjs.cc

+26
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,32 @@ NAN_METHOD(mouseClick)
7171

7272
MMMouseButton button = LEFT_BUTTON;
7373

74+
if (args.Length() == 1)
75+
{
76+
char *but = (*v8::String::Utf8Value(args[0]->ToString()));
77+
78+
if (strcmp(but, "left") == 0)
79+
{
80+
button = LEFT_BUTTON;
81+
}
82+
else if (strcmp(but, "right") == 0)
83+
{
84+
button = RIGHT_BUTTON;
85+
}
86+
else if (strcmp(but, "middle") == 0)
87+
{
88+
button = CENTER_BUTTON;
89+
}
90+
else
91+
{
92+
return NanThrowError("Invalid mouse button specified.");
93+
}
94+
}
95+
else if (args.Length() > 1)
96+
{
97+
return NanThrowError("Invalid number of arguments.");
98+
}
99+
74100
clickMouse(button);
75101

76102
NanReturnValue(NanNew("1"));

0 commit comments

Comments
 (0)