ELECTRON-592 - Prevent custom title bar buttons from taking focus (#478)

This commit is contained in:
Kiran Niranjan 2018-08-28 11:49:01 +05:30 committed by Vishwas Shashidhar
parent 29fb713b75
commit e5fb89842b

View File

@ -77,6 +77,11 @@ class TitleBar {
attachEventListeners(this.closeButton, 'click', this.closeWindow.bind(this));
attachEventListeners(this.maximizeButton, 'click', this.maximizeOrUnmaximize.bind(this));
attachEventListeners(this.minimizeButton, 'click', this.minimize.bind(this));
attachEventListeners(this.hamburgerMenuButton, 'mousedown', TitleBar.handleMouseDown.bind(this));
attachEventListeners(this.closeButton, 'mousedown', TitleBar.handleMouseDown.bind(this));
attachEventListeners(this.maximizeButton, 'mousedown', TitleBar.handleMouseDown.bind(this));
attachEventListeners(this.minimizeButton, 'mousedown', TitleBar.handleMouseDown.bind(this));
}
/**
@ -212,6 +217,14 @@ class TitleBar {
isValidWindow() {
return !!(this.window && !this.window.isDestroyed());
}
/**
* Prevent default to make sure buttons don't take focus
* @param e
*/
static handleMouseDown(e) {
e.preventDefault();
}
}
/**