Skip to content

Commit

Permalink
Added right/middle click support, closes #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Feb 4, 2015
1 parent e981548 commit 2fc100a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,32 @@ NAN_METHOD(mouseClick)

MMMouseButton button = LEFT_BUTTON;

if (args.Length() == 1)
{
char *but = (*v8::String::Utf8Value(args[0]->ToString()));

if (strcmp(but, "left") == 0)
{
button = LEFT_BUTTON;
}
else if (strcmp(but, "right") == 0)
{
button = RIGHT_BUTTON;
}
else if (strcmp(but, "middle") == 0)
{
button = CENTER_BUTTON;
}
else
{
return NanThrowError("Invalid mouse button specified.");
}
}
else if (args.Length() > 1)
{
return NanThrowError("Invalid number of arguments.");
}

clickMouse(button);

NanReturnValue(NanNew("1"));
Expand Down

0 comments on commit 2fc100a

Please sign in to comment.