From f21aec52266a645adf9936f3d33262717982b1c9 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 20 Jan 2018 16:15:55 +0000 Subject: [PATCH] Add keyboard shortcut Also fixes bug where pressing escape with another dialog open closes both at once --- .../ui/vue/components/BdSettingsWrapper.vue | 28 +++++++++++++++---- .../templates/BdSettingsWrapper.html | 4 +-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/client/src/modules/ui/vue/components/BdSettingsWrapper.vue b/client/src/modules/ui/vue/components/BdSettingsWrapper.vue index a7784a6a..7fce26a2 100644 --- a/client/src/modules/ui/vue/components/BdSettingsWrapper.vue +++ b/client/src/modules/ui/vue/components/BdSettingsWrapper.vue @@ -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; - this.hideSettings(); + 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); } } - \ No newline at end of file + diff --git a/client/src/modules/ui/vue/components/templates/BdSettingsWrapper.html b/client/src/modules/ui/vue/components/templates/BdSettingsWrapper.html index 7b72e058..05687f4c 100644 --- a/client/src/modules/ui/vue/components/templates/BdSettingsWrapper.html +++ b/client/src/modules/ui/vue/components/templates/BdSettingsWrapper.html @@ -1,6 +1,6 @@ -
+
-
\ No newline at end of file +