Add keyboard shortcut
Also fixes bug where pressing escape with another dialog open closes both at once
This commit is contained in:
parent
f9cd4e1a8a
commit
f21aec5226
|
@ -10,17 +10,35 @@
|
|||
|
||||
const methods = { showSettings, hideSettings };
|
||||
|
||||
let keydownEvent;
|
||||
|
||||
export default {
|
||||
components,
|
||||
methods,
|
||||
data() {
|
||||
return { active: false }
|
||||
return {
|
||||
active: false,
|
||||
platform: global.process.platform
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
window.addEventListener('keyup', e => {
|
||||
if (e.which !== 27) return;
|
||||
window.addEventListener('keydown', keydownEvent = e => {
|
||||
if (this.active) {
|
||||
if (e.which === 27)
|
||||
this.hideSettings();
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
});
|
||||
},
|
||||
destroyed: function() {
|
||||
window.removeEventListener('keydown', keydownEvent);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,4 +1,4 @@
|
|||
<div class="bd-settings-wrapper" :class="{active: active}">
|
||||
<div class="bd-settings-wrapper" :class="[{active: active}, 'platform-' + this.platform]">
|
||||
<div class="bd-settings-button" :class="{active: active}" @click="showSettings">
|
||||
<div class="bd-settings-button-btn"></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue