Skip to content

Commit a3346ab

Browse files
committed
Accept "up" or "down" for direction.
1 parent 062be3f commit a3346ab

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/robotjs.cc

+16-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,22 @@ NAN_METHOD(scrollMouse)
199199
if(info.Length() == 2)
200200
{
201201
int scrollMagnitude = info[0]->Int32Value();
202-
int scrollDirection = info[1]->Int32Value();
202+
char *s = (*v8::String::Utf8Value(info[1]->ToString()));
203+
204+
MMMouseWheelDirection scrollDirection;
205+
206+
if (strcmp(s, "up") == 0)
207+
{
208+
scrollDirection = DIRECTION_UP;
209+
}
210+
else if (strcmp(s, "down") == 0)
211+
{
212+
scrollDirection = DIRECTION_DOWN;
213+
}
214+
else
215+
{
216+
return Nan::ThrowError("Invalid scroll direction specified.");
217+
}
203218

204219
scrollMouse(scrollMagnitude, scrollDirection);
205220
microsleep(mouseDelay);

0 commit comments

Comments
 (0)