How to use the nw.gui.Shortcut 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 csound / csound / examples / html / csound_editor / main.html View on Github external
var csound = require('csound');
        var csound_window = null;
        var gui = require('nw.gui');
        var fs = require('fs');
        var option = {
            key : "F11",
            active : function() {
                console.log("Global desktop keyboard shortcut: " + this.key + " active.");
                csound_window.toggleFullscreen();
            },
            failed : function(msg) {
                // :(, fail to register the |key| or couldn't parse the |key|.
                console.log(msg);
            }
        };
        var shortcut = new gui.Shortcut(option);
        gui.App.registerGlobalHotKey(shortcut);
        function csound_run()
        {
            console.log('csound_run()...');
            filename = filename.replace(/\\/g,"/");
            console.log('filename: ' + filename);
            // Thre are two file modes for csound.node:
            // .html files, which must always create their own csound object with
            // require('csound');, and .csd files, which assume that the csound
            // object has already been created in their JavasScript context.
            if (filename.endsWith('.html')) {
                csound_window = gui.Window.open('file:///' + filename,
                    {
                        "position": 'center',
                        "nodejs": true,
                        "new-instance": false,
github egoist / Miu / resource / js / app.js View on Github external
var path = require("path");

var lang = simpleStorage.get("language") || "en";
// Create a shortcut with |option|.
var option = {
    key:"Ctrl+M",
    active:function() {
        console.log("Global desktop keyboard shortcut: " + this.key + " active.");
    },
    failed:function(msg) {
        // :(, fail to register the |key| or couldn't parse the |key|.
        console.log(msg);
    }
};

var shortcut = new gui.Shortcut(option);

var tray;

self.show = true;

// Create a tray icon
tray = new gui.Tray({
    title:"Miu",
    icon:"miu.png"
});

var menu = new gui.Menu();

var startItem = new gui.MenuItem({
    type:"normal",
    label:"Miu",
github slonka / fuzzyclipboard / app / js / index.js View on Github external
var win = gui.Window.get();

var option = {
    key: "Ctrl+Shift+V",
    active: function(event) {
        win.show();
        win.focus();
    },
    failed: function(msg) {
        // :(, fail to register the |key| or couldn't parse the |key|.
        console.log(msg);
    }
};

// Create a shortcut with |option|.
var shortcut = new gui.Shortcut(option);

// Register global desktop shortcut, which can work without focus.
gui.App.registerGlobalHotKey(shortcut);

win.on('close', function() {
    // Unregister the global desktop shortcut.
    gui.App.unregisterGlobalHotKey(shortcut);
    this.close(true);
});

win.minimize();

// Get the minimize event
win.on('minimize', function() {
    // Hide window
    this.hide();
github lufengd3 / GulpIDE / win / main.js View on Github external
addProjectToList(localStorage.newProject);
            } else {
                alert(err + ' Path is: ' + localStorage.newProject);
            }
            delete localStorage.newProject;
        });
    }
    refreshProjectList();
    // load last opening file
    if (typeof localStorage.openning !== 'undefined' && localStorage.openning !== '') {
        openGulpFile(localStorage.openning);
    }

    // Create a shortcut with |option|.
    shortcutSave = new gui.Shortcut({key : "Ctrl+S"});
    shortcutNew = new gui.Shortcut({key : "Ctrl+N"});
    shortcutOpen = new gui.Shortcut({key : "Ctrl+O"});
    shortcutSave.on('active', function() {
        saveGulpFile();
    });
    shortcutNew.on('active', function() {
        createNewProject();
    });
    shortcutOpen.on('active', function() {
        openProject();
    });
    gui.Window.get().focus();
}
github nwjs / nw.js / tests / manual_tests / global_hotkey / index.html View on Github external
var shortcut3 = new gui.Shortcut(option);

      option.key = "Ctrl+Alt+C";
      var shortcut4 = new gui.Shortcut(option);

      option.key = "MediaPrevTrack";
      var shortcut5 = new gui.Shortcut(option);

      option.key = "MediaNextTrack";
      var shortcut6 = new gui.Shortcut(option);

      option.key = "MediaPlayPause";
      var shortcut7 = new gui.Shortcut(option);

      option.key = "MediaStop";
      var shortcut8 = new gui.Shortcut(option);

      gui.App.registerGlobalHotKey(shortcut1)
      gui.App.registerGlobalHotKey(shortcut2);
      gui.App.registerGlobalHotKey(shortcut3);
      gui.App.registerGlobalHotKey(shortcut4);
      gui.App.registerGlobalHotKey(shortcut5);
      gui.App.registerGlobalHotKey(shortcut6);
      gui.App.registerGlobalHotKey(shortcut7);
      gui.App.registerGlobalHotKey(shortcut8);

      function unregister() {
        gui.App.unregisterGlobalHotKey(shortcut2);
        gui.App.unregisterGlobalHotKey(shortcut3);
      }
github nwjs / nw.js / tests / manual_tests / global_hotkey / index.html View on Github external
function active() {
        log(JSON.stringify(this) + ": Actived");
      }

      var gui = require('nw.gui');
      var option = {active: active, failed: failed};

      option.key = "Alt+Shift+A";
      var shortcut1 = new gui.Shortcut(option);

      option.key = "Ctrl+K";
      var shortcut2 = new gui.Shortcut(option);

      option.key = "Alt+B";
      var shortcut3 = new gui.Shortcut(option);

      option.key = "Ctrl+Alt+C";
      var shortcut4 = new gui.Shortcut(option);

      option.key = "MediaPrevTrack";
      var shortcut5 = new gui.Shortcut(option);

      option.key = "MediaNextTrack";
      var shortcut6 = new gui.Shortcut(option);

      option.key = "MediaPlayPause";
      var shortcut7 = new gui.Shortcut(option);

      option.key = "MediaStop";
      var shortcut8 = new gui.Shortcut(option);
github nwjs / nw.js / tests / manual_tests / global_hotkey / index.html View on Github external
}

      var gui = require('nw.gui');
      var option = {active: active, failed: failed};

      option.key = "Alt+Shift+A";
      var shortcut1 = new gui.Shortcut(option);

      option.key = "Ctrl+K";
      var shortcut2 = new gui.Shortcut(option);

      option.key = "Alt+B";
      var shortcut3 = new gui.Shortcut(option);

      option.key = "Ctrl+Alt+C";
      var shortcut4 = new gui.Shortcut(option);

      option.key = "MediaPrevTrack";
      var shortcut5 = new gui.Shortcut(option);

      option.key = "MediaNextTrack";
      var shortcut6 = new gui.Shortcut(option);

      option.key = "MediaPlayPause";
      var shortcut7 = new gui.Shortcut(option);

      option.key = "MediaStop";
      var shortcut8 = new gui.Shortcut(option);

      gui.App.registerGlobalHotKey(shortcut1)
      gui.App.registerGlobalHotKey(shortcut2);
      gui.App.registerGlobalHotKey(shortcut3);
github teak / Pussh / Resources / js / index.js View on Github external
}

                            console.log('Uploading %s', filePath);

                            var newFile = _self.moveToTemp(filePath);

                            _self.upload(newFile, filePath);
                        });
                    });

                    checkedFiles = files;
                }
            });
        }, 1000);
    } else if (platform == 'win32') {
        var windowsFullScreenshot = new gui.Shortcut({
            key: "Alt+Shift+3",
            active: function() {
                _self.windowsCapture(false);
            }
        });

        var windowsCropScreenshot = new gui.Shortcut({
            key: "Alt+Shift+4",
            active: function() {
                _self.windowsCapture(true);
            }
        });

        gui.App.registerGlobalHotKey(windowsFullScreenshot);
        gui.App.registerGlobalHotKey(windowsCropScreenshot);
    }
github octalmage / pixelcolor / app.js View on Github external
{
			start();
		}
		else
		{
			clearTimeout(timer);
			timer = null;
		}
	},
	failed: function(msg)
	{
		console.log(msg);
	}
};

var shortcut = new gui.Shortcut(pauseHotkey);

gui.App.registerGlobalHotKey(shortcut);

//Needed for copy/paste on Mac.
if (process.platform === "darwin")
{
	var nativeMenuBar = new gui.Menu(
	{
		type: "menubar"
	});
	nativeMenuBar.createMacBuiltin("PixelColor");
	win.menu = nativeMenuBar;
}

$(document).on("ready", function() 
{
github octalmage / HotGifs / app.js View on Github external
//Workaround to focus the input after showing.
		setTimeout(function()
		{
			win.focus();
			$("#s").focus();
		}, 0);

		if (!settings.get('opt-out')) visitor.event("User interaction", "Window Open").send();
	},
	failed: function(msg)
	{
		console.log(msg);
	}
};

var shortcut = new gui.Shortcut(option);

gui.App.registerGlobalHotKey(shortcut);

//Startup check.
runatstartup.isEnabled(function(found)
{
	if (found)
	{
		startup.checked = true;
	}
});

$(document).on("ready", function()
{
	if (settings.get('check-for-updates'))
	{