Book Image

NW.js Essentials

By : Alessandro Benoit, Roger Weng
Book Image

NW.js Essentials

By: Alessandro Benoit, Roger Weng

Overview of this book

Table of Contents (17 chapters)
NW.js Essentials
About the Author
About the Reviewers

The NativeUI layer

As we have done with the application layer, before writing any line of code, we'd better take a look at which features we need the NativeUI layer to implement:

  • Implement a Window menu

  • Implement a Context menu on the to-dos content

  • Restore the Main window position when opening the application

  • Implement an Options window

  • On exit, store the windows position, let the Options window save data and compact the database

  • Open the application smoothly when everything has been loaded

First, we need to call myApp.nativeUI.init() from inside myApp.init() in js/main.js, and then we can open the js/nativeui.js file and add the following code:

myApp.nativeUI = {};
myApp.nativeUI.init = function () {
  // Instance nw.gui
  myApp.gui = require('nw.gui');
  // Globals
  myApp.mainWindow = myApp.gui.Window.get(); =;
  // -- Call the other functions here --
// -- Declare the other functions here --

In the first two rows, we performed the following actions...