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 };
|
const methods = { showSettings, hideSettings };
|
||||||
|
|
||||||
|
let keydownEvent;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components,
|
components,
|
||||||
methods,
|
methods,
|
||||||
data() {
|
data() {
|
||||||
return { active: false }
|
return {
|
||||||
|
active: false,
|
||||||
|
platform: global.process.platform
|
||||||
|
}
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
window.addEventListener('keyup', e => {
|
window.addEventListener('keydown', keydownEvent = e => {
|
||||||
if (e.which !== 27) return;
|
if (this.active) {
|
||||||
|
if (e.which === 27)
|
||||||
this.hideSettings();
|
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>
|
</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" :class="{active: active}" @click="showSettings">
|
||||||
<div class="bd-settings-button-btn"></div>
|
<div class="bd-settings-button-btn"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue