How to use the nw.gui.global function in nw

To help you get started, we’ve selected a few nw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XRoemer / sequencer-and-editor / js / init / init.js View on Github external
nw_gui.App.on('open', function (argString) {

  argString = argString.split(' ')
  var nr = argString[argString.length - 1]

  if (!open_windows[nr]) {
 // search for window with the lowest win_nr
    // to open a new window just once
    var wins = nw_gui.global.__nw_windows
    var keys = Object.keys(wins)
    var win_nrs = []
    keys.forEach(function(e) {
      win_nrs.push(wins[e][0].window.win_nr)
      })
    win_nrs.sort()
    var is_win_with_lowest_nr = window.win_nr == win_nrs[0].toString()
    if (is_win_with_lowest_nr) {
      log('opened sequencer',nr)
      open_new_sequencer_window(nr)
    }
  }
  else {
    // hack for not working window.focus()
    chrome.windows.update(open_windows[nr].id, {focused : true});
  }