From 8668999724ffc25580e346ac35e6a8d6d7bb39c2 Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Tue, 11 Apr 2017 19:58:54 -0300 Subject: [PATCH] Fixed focus on Alt+Tab and click Fixes #483 Related https://github.com/electron/electron/issues/5900 --- app.js | 4 ++++ electron/main.js | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 902591d8..7cf1c650 100644 --- a/app.js +++ b/app.js @@ -124,3 +124,7 @@ ipc.on('reloadCurrentService', function(e) { var tab = Ext.cq1('app-main').getActiveTab(); if ( tab.id !== 'ramboxTab' ) tab.reloadService(); }); +// Focus the current service when Alt + Tab or click in webviews textfields +window.addEventListener('focus', function() { + if(Ext.cq1("app-main")) Ext.cq1("app-main").getActiveTab().down('component').el.dom.focus(); +}); diff --git a/electron/main.js b/electron/main.js index f0fd5ca7..f613a45c 100644 --- a/electron/main.js +++ b/electron/main.js @@ -184,10 +184,7 @@ function createWindow () { // Navigate the window forward when the user hits their mouse forward button if ( cmd === 'browser-forward' ) mainWindow.webContents.executeJavaScript('if(Ext.cq1("app-main")) Ext.cq1("app-main").getActiveTab().goForward();'); }); - mainWindow.on('focus', (e) => { - // Make focus on current service when user use Alt + Tab to activate Rambox - mainWindow.webContents.executeJavaScript('if(Ext.cq1("app-main")) Ext.cq1("app-main").fireEvent("tabchange", Ext.cq1("app-main"), Ext.cq1("app-main").getActiveTab());'); - }); + // Emitted when the window is closed. mainWindow.on('close', function(e) { if ( !isQuitting ) {