Update BdSettingsWrapper.vue
No need to check for platform and return instead of if else. We can also hide settings with Ctrl/Cmd+b
This commit is contained in:
parent
f21aec5226
commit
abda678167
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
const methods = { showSettings, hideSettings };
|
const methods = { showSettings, hideSettings };
|
||||||
|
|
||||||
let keydownEvent;
|
let globalKeyListener;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components,
|
components,
|
||||||
|
@ -22,23 +22,20 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
window.addEventListener('keydown', keydownEvent = e => {
|
window.addEventListener('keyup', globalKeyListener = e => {
|
||||||
if (this.active) {
|
if (this.active && e.which === 27) {
|
||||||
if (e.which === 27)
|
|
||||||
this.hideSettings();
|
this.hideSettings();
|
||||||
} else {
|
return;
|
||||||
if (global.process.platform == 'darwin' && e.metaKey && e.key == 'b')
|
|
||||||
this.showSettings();
|
|
||||||
else if (global.process.platform != 'darwin' && e.ctrlKey && e.key == 'b')
|
|
||||||
this.showSettings();
|
|
||||||
else return;
|
|
||||||
}
|
}
|
||||||
|
if (!e.metaKey && !e.ctrlKey && e.key !== 'b') return;
|
||||||
|
|
||||||
|
!this.active ? this.showSettings() : this.hideSettings();
|
||||||
|
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
destroyed: function () {
|
destroyed: function () {
|
||||||
window.removeEventListener('keydown', keydownEvent);
|
if (globalKeyListener) window.removeEventListener('keyup', globalKeyListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue