How to use the nw.gui.MenuItem 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 capablemonkey / sleep / app / js / index.js View on Github external
tray = new gui.Tray({ icon: 'assets/icon2.png'});

	/*
	 *	create the main tray menu and its items
	 */

	trayMenu = new gui.Menu();
	trayMenuItems.lastSlept = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.lastWoke = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.duration = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.sep1 = new gui.MenuItem({type: 'separator'});
	trayMenuItems.reasonLabel = new gui.MenuItem({type: 'normal', label: 'reason for sleep:', enabled: false});
	trayMenuItems.reason = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.sep2 = new gui.MenuItem({type: 'separator'});
	trayMenuItems.startup = new gui.MenuItem({type: 'checkbox', label: 'run on login?', checked: false});
	trayMenuItems.about = new gui.MenuItem({type: 'normal', label: 'about'});
	trayMenuItems.quit = new gui.MenuItem({ type: 'normal', label: 'quit', enabled: true });

	// TODO: make a button to refresh 
	
	/*
	 *	Logic + Event handling for MenuItems
	 */

	trayMenuItems.about.click = function() {
		var win = gui.Window.get();
		win.show();
		win.focus();
	};
	
	trayMenuItems.quit.click = function() { gui.App.quit(); }
github agraef / purr-data / pd / nw / pd_canvas.html View on Github external
pdgui.pdsend(name, "paste");
        },
        tooltip: l('menu.paste_tt'),
    }));

    editMenu.append(new nw.MenuItem({
        label:  l('menu.duplicate'),
        click: function () {
            pdgui.pdsend(name, "duplicate");
        },
        key: 'd',
        modifiers: "ctrl",
        tooltip: l('menu.duplicate_tt')
    }));

    editMenu.append(modals.selectall = new nw.MenuItem({
        label: l('menu.selectall'),
        click: function (evt) {
            if (canvas_events.get_state() === 'normal') {
                pdgui.pdsend(name, "selectall");
            }
        },
        tooltip: l('menu.selectall_tt'),
    }));

    editMenu.append(new nw.MenuItem({
        label: l('menu.reselect'),
        // Unfortunately nw.js doesn't allow
        // key: "Return" or key: "Enter", so we
        // can't bind to ctrl-Enter here. (Even
        // tried fromCharCode...)
        click: function () {
github paulbjensen / lens-photo-app / app.js View on Github external
function loadMenu () {
	var menuBar 	= new gui.Menu({type:'menubar'});
	var menuItems 	= new gui.Menu();

	menuItems.append(new gui.MenuItem({ label: 'Load another folder', click: loadAnotherFolder }));

	var fileMenu = new gui.MenuItem({
		label: 'File',
		submenu: menuItems
	});

	if (process.platform === 'darwin') {

		// Load Mac OS X application menu
		menuBar.createMacBuiltin('Lens');
		menuBar.insert(fileMenu, 1);

	} else {

		// Load Windows/Linux application menu
		menuBar.append(fileMenu, 1);
github cgrossde / Pullover / src / app / nw / Tray.js View on Github external
// Separator
var itemSeparator = new Gui.MenuItem({ type: 'separator' })
// Show status
var itemStatus = new Gui.MenuItem({ type: 'normal', label: 'Status' })
itemStatus.on('click', function() {
  showWindow()
  transitionTo('/status')
})
// Show notification list
var notifications = new Gui.MenuItem({ type: 'normal', label: 'Notifications' })
notifications.on('click', function() {
  showWindow()
  transitionTo('/notifications')
})
// Quit app
var itemQuit = new Gui.MenuItem({ type: 'normal', label: 'Quit Pullover' })
itemQuit.on('click', quitApp)

// Build tray click menu
var menu = new Gui.Menu()
menu.append(itemStatus)
menu.append(notifications)
menu.append(itemSeparator)
menu.append(itemQuit)
tray.menu = menu
tray.on('click', showWindow)
github fimkrypto / mofowallet / app / scripts / lib / nw-edit-menu.js View on Github external
label: cutLabel || "Cut"
        , click: function() {
          document.execCommand("cut");
          console.log('Menu:', 'cutted to clipboard');
        }
      })

      , copy = new gui.MenuItem({
        label: copyLabel || "Copy"
        , click: function() {
          document.execCommand("copy");
          console.log('Menu:', 'copied to clipboard');
        }
      })

      , paste = new gui.MenuItem({
        label: pasteLabel || "Paste"
        , click: function() {
          document.execCommand("paste");
          console.log('Menu:', 'pasted to textarea');
        }
      })
    ;

    menu.append(cut);
    menu.append(copy);
    menu.append(paste);

    return menu;
  }
github Dregu / nwsplit / index.html View on Github external
gui.App.registerGlobalHotKey(new gui.Shortcut({key: options.global_reset,active: function(){reset()},failed: function(msg){console.log(msg)}}))
  gui.App.registerGlobalHotKey(new gui.Shortcut({key: options.global_pause,active: function(){pause()},failed: function(msg){console.log(msg)}}))
  if(localStorage.x) {
    win.x = localStorage.x
  }
  if(localStorage.y) {
    win.y = localStorage.y
  }
  if(localStorage.width) {
    win.width = localStorage.width
  }
  if(localStorage.height) {
    win.height = localStorage.height
  }
  var menu = new gui.Menu()
  menu.append(new gui.MenuItem({ label: 'Import splits' }))
  menu.append(new gui.MenuItem({ label: 'Export splits' }))
  menu.append(new gui.MenuItem({ type: 'separator' }))
  menu.append(new gui.MenuItem({ label: 'Start / Split' }))
  menu.append(new gui.MenuItem({ label: 'Stop / PBs to splits' }))
  menu.append(new gui.MenuItem({ label: 'Pause / Unpause' }))
  menu.append(new gui.MenuItem({ label: 'Reset' }))
  menu.append(new gui.MenuItem({ label: 'Clear all' }))
  menu.append(new gui.MenuItem({ label: 'Undo split' }))
  menu.append(new gui.MenuItem({ label: 'Add split' }))
  menu.append(new gui.MenuItem({ type: 'separator' }))
  menu.append(new gui.MenuItem({ label: 'Change options' }))
  menu.append(new gui.MenuItem({ label: 'Add custom theme' }))
  menu.append(new gui.MenuItem({ label: 'Clear custom theme' }))
  menu.append(new gui.MenuItem({ label: 'Load defaults' }))
  menu.append(new gui.MenuItem({ label: 'Show graph' }))
  menu.append(new gui.MenuItem({ label: 'Show toolbar' }))
github HuayraLinux / huayra-stopmotion / src / js / services / menu.js View on Github external
this.item_salir = new gui.MenuItem({
        label: 'Salir',
        click: function() {
            gui.App.closeAllWindows();
        }
    });

    this.item_generar_video = new gui.MenuItem({
        label: 'Generar video',
        click: function() {
            self.funcion_exportar.call(this);
        }
    });

    this.item_acerca_de = new gui.MenuItem({
        label: 'Acerca de ...',
        click: function() {
            self.funcion_acerca_de.call(this);
        }
    });

    this.alternar_ayuda = function() {
        panel_ayuda.classList.toggle('ayuda-invisible');
    }

    this.deshabilitar_guardado = function() {
        this.item_guardar.enabled = false;
        this.item_guardar_como.enabled = false;
    }

    this.deshabilitar_guardado();
github rockiger / akiee / editor.js View on Github external
function initContextMenu() {
  menu = new gui.Menu();
  menu.append(new gui.MenuItem({
    label: 'Copy',
    click: function() {
      clipboard.set(editor.getSelection());
    }
  }));
  menu.append(new gui.MenuItem({
    label: 'Cut',
    click: function() {
      clipboard.set(editor.getSelection());
      editor.replaceSelection('');
    }
  }));
  menu.append(new gui.MenuItem({
    label: 'Paste',
    click: function() {
      editor.replaceSelection(clipboard.get());
    }
  }));

  document.getElementById("editor").addEventListener('contextmenu',
                                                     function(ev) { 
    ev.preventDefault();
    menu.popup(ev.x, ev.y);
    return false;
  });
}
github agraef / purr-data / pd / nw / pd_canvas.html View on Github external
label: l('menu.cut'),
        click: function () {
            pdgui.pdsend(name, "cut");
        },
        tooltip: l('menu.cut_tt'),
    }));

    editMenu.append(modals.copy = new nw.MenuItem({
        label: l('menu.copy'),
        click: function () {
            pdgui.pdsend(name, "copy");
        },
        tooltip: l('menu.copy_tt'),
    }));

    editMenu.append(modals.paste = new nw.MenuItem({
        label: l('menu.paste'),
        click: function () {
            pdgui.pdsend(name, "paste");
        },
        tooltip: l('menu.paste_tt'),
    }));

    editMenu.append(new nw.MenuItem({
        label:  l('menu.duplicate'),
        click: function () {
            pdgui.pdsend(name, "duplicate");
        },
        key: 'd',
        modifiers: "ctrl",
        tooltip: l('menu.duplicate_tt')
    }));
github zcbenz / nw-sample-apps / menus / script.js View on Github external
submenu.append(new gui.MenuItem({ type: 'checkbox', label: 'box4' }));
menu1.append(new gui.MenuItem({ icon: 'imgs/cut.png', label: 'Cut' }));
menu1.append(new gui.MenuItem({ icon: 'imgs/edit.png', label: 'Edit' }));
menu1.append(new gui.MenuItem({ icon: 'imgs/email.png', label: 'Email' }));
menu1.append(new gui.MenuItem({ icon: 'imgs/play.png', label: 'Play' }));
menu1.append(new gui.MenuItem({ icon: 'imgs/tick.png', label: 'Tick' }));
menu1.append(new gui.MenuItem({ type: 'separator' }));
menu1.append(new gui.MenuItem({ icon: 'imgs/disk.png', label: 'Disk', submenu: submenu }));

var menu2 = new gui.Menu();
menu2.append(new gui.MenuItem({ type: 'checkbox', label: 'Apple' }));
menu2.append(new gui.MenuItem({ type: 'checkbox', label: 'Banana' }));
menu2.append(new gui.MenuItem({ type: 'checkbox', label: 'Strawberry' }));
menu2.append(new gui.MenuItem({ type: 'checkbox', label: 'Pear' }));
menu2.append(new gui.MenuItem({ type: 'separator' }));
var info_item = new gui.MenuItem({ label: 'Which Fruit Do I Love?' });
menu2.append(info_item);
var lastone = null;
function flip() {
  if (lastone) {
    lastone.checked = false;
    lastone.enabled = true;
  }
  lastone = this;
  this.enabled = false;
  info_item.label = 'I Love ' + this.label;
}
for (var i = 0; i < 4; ++i)
  menu2.items[i].click = flip;

var menu3 = new gui.Menu();
var colors = [ '#000000', '#FF0000', '#00FF00' , '#0000FF', '#FFFF00', '#00FFFF', '#FF00FF', '#C0C0C0', '#FFFFFF' ];