Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui Global Shortcut masking keyboard events from other Running Application #2636

Closed
kamesh-a opened this issue Nov 17, 2014 · 3 comments
Closed

Comments

@kamesh-a
Copy link

Hello,

There is issue, which we are able to see when trying to use Global shortcuts gui.Shortcut, when we register a command say "ctrl+f".

Expected Behaviour : shortcut should work within the app, Yea it works, but
Defered behaviour: when app is background, say for example we are active in some other app "chrome" perhaps, if we initiate the same key press, it goes to my node-webkit app instead of that active app, plus keyboard ns event does NOT bubble to other application. Search bar not shows up in "chrome".

snippet:

var gui = require('nw.gui');

var option = {
  key : "Ctrl+f",
  active : function() {
    console.log("Only Node Webkit app will recieve this KEYpress, NO other apps even when they are active !!!"); 
  },
  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);
// Registering Global HotKey
gui.App.registerGlobalHotKey(shortcut);

Tested both in 0.10.6 and 0.11 build.

System Specs:
OS : OS X yosemite 10.10 and Maverics.


Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

@kamesh-a
Copy link
Author

kamesh-a commented Dec 4, 2014

@rogerwang Hi, do we have any idea on this, flaw I can try to code and fix this, if you could provide any usable info.

@tommoor tommoor added the bug label Jan 18, 2015
@leifwells
Copy link

I am seeing the same behavior in Mac OS X Yosemite 10.10.1 with 0.12.alpha2

@mrfabbri
Copy link
Member

mrfabbri commented Feb 8, 2015

Hi @kamesh-a, this is the expected behaviour. The shortcut is global, i.e. system-wide, so, yes, it will override other shortcuts (otherwise it won't work when the app is not active), the documentation in Shortcut is clear: "If registered successfully, it works even if your app does not have focus".

If you want to implement application wide shortcuts you may have a look at https://gist.github.com/mrfabbri/3a32baf9c5eb5a446a48.

@mrfabbri mrfabbri closed this as completed Feb 8, 2015
@mrfabbri mrfabbri removed the bug label Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants