Skip to content

Commit

Permalink
Added getScreenSize, closes #25.
Browse files Browse the repository at this point in the history
This returns and object with the width and height.

Example: { width: 1280, height: 800 }
  • Loading branch information
octalmage committed Apr 25, 2015
1 parent 845a838 commit d94ca48
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,22 @@ NAN_METHOD(getPixelColor)
NanReturnValue(NanNew(hex));
}

NAN_METHOD(getScreenSize)
{
NanScope();

//Get display size.
MMSize displaySize = getMainDisplaySize();

//Create our return object.
Local<Object> obj = NanNew<Object>();
obj->Set(NanNew<String>("width"), NanNew<Number>(displaySize.width));
obj->Set(NanNew<String>("height"), NanNew<Number>(displaySize.height));

//Return our object with .width and .height.
NanReturnValue(obj);
}

void init(Handle<Object> target)
{

Expand Down Expand Up @@ -319,6 +335,9 @@ void init(Handle<Object> target)
target->Set(NanNew<String>("getPixelColor"),
NanNew<FunctionTemplate>(getPixelColor)->GetFunction());

target->Set(NanNew<String>("getScreenSize"),
NanNew<FunctionTemplate>(getScreenSize)->GetFunction());

}

NODE_MODULE(robotjs, init)

0 comments on commit d94ca48

Please # to comment.