Skip to content

Commit

Permalink
Accept "up" or "down" for direction.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Oct 4, 2015
1 parent 062be3f commit a3346ab
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,22 @@ NAN_METHOD(scrollMouse)
if(info.Length() == 2)
{
int scrollMagnitude = info[0]->Int32Value();
int scrollDirection = info[1]->Int32Value();
char *s = (*v8::String::Utf8Value(info[1]->ToString()));

MMMouseWheelDirection scrollDirection;

if (strcmp(s, "up") == 0)
{
scrollDirection = DIRECTION_UP;
}
else if (strcmp(s, "down") == 0)
{
scrollDirection = DIRECTION_DOWN;
}
else
{
return Nan::ThrowError("Invalid scroll direction specified.");
}

scrollMouse(scrollMagnitude, scrollDirection);
microsleep(mouseDelay);
Expand Down

0 comments on commit a3346ab

Please sign in to comment.