Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node-Webkit (nwjs) How to align window to the right?

Is there any simple way to align window of Node-Webkit application? As far as I can see in documentation there is such metod as Window.moveTo(), as well as property "position", which nevertheless could have only 3 values: "center", "mouse" and null. So in order to align the app by the right side of monitor I need to move window manually from code on start, or are there any other way?

like image 750
SLoN1ck Avatar asked Mar 16 '14 14:03

SLoN1ck


1 Answers

  1. Use javascript window.screen.availHeight and window.screen.availWidth (which excludes window decorations n toolbar)
    or

    window.screen.height and window.screen.width (which includes window decorations n toolbar) to get the screen resolution.

  2. In node-webkit package.json set

    "window": { "show": false } this will hide the node-webkit window initially.

  3. var appWidth = 400; // width of your application

  4. Use window.moveTo(window.screen.availWidth - appWidth, 40);

  5. Use window.show(); to show the window

this allows to place window anywhere on screen

like image 161
Harsh Avatar answered Sep 29 '22 05:09

Harsh