Blur event stops working after the first time PanelWindow is hidden
If you create a PanelWindow with show: false, the blur event will never be sent. In my example below, I have a keyboard shortcut to show a window, and the blur never fires in that case.
If you enable the show property, the blur event will fire until the window is hidden for the first time. So, in my example below, the blur event fires, but once barWindow.hide() is called (either using the shortcut or by activating a different application), it will never fire again.
Example (Electron 4.2.5):
const { app, globalShortcut, BrowserWindow } = require('electron');
const { PanelWindow } = require('electron-panel-window');
let barWindow = null;
const debug = false;
app.on('ready', function() {
const barWindow = new PanelWindow({
width: 700,
backgroundColor: '#FF0000',
height: 700,
show: false,
// frameless does not work in PanelWindow
// frame: false
});
barWindow.loadFile(`./main.html`);
if (debug === false) {
barWindow.on('blur', function(event) {
console.log('BLUR');
barWindow.hide();
app.hide();
});
}
const shortcut = 'Alt+CommandOrControl+Space' // 'CommandOrControl+Space'
globalShortcut.register(shortcut, () => {
if (barWindow.isVisible()) {
barWindow.hide();
// app.hide();
} else {
barWindow.show();
}
console.log(`${shortcut} is pressed`);
// barWindow.webContents.openDevTools({ options: { mode: 'detach' } });
});
});
hi @probablykasper did you find it out ?
@castroCrea No, I don't think so
There's qazbnm456's fork, which I think also has this issue. Might be worth giving it a try because it's a while since I tried it.
Found electron-nspanel, which has this problem as well as input elements focus seeming to not to work.