Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Blur event stops working after the first time PanelWindow is hidden #4

Open
probablykasper opened this issue Jun 29, 2019 · 2 comments

Comments

@probablykasper
Copy link

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' } });
	});
});
@castroCrea
Copy link

hi @probablykasper did you find it out ?

@probablykasper
Copy link
Author

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants