mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-29 03:21:49 +00:00
Fixed hotkeys not being reactive
This commit is contained in:
parent
36f91f91c3
commit
56b1a7a9b4
1 changed files with 20 additions and 8 deletions
|
@ -13,22 +13,34 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { GenericHotkey } from "features/hotkey";
|
import { GenericHotkey } from "features/hotkey";
|
||||||
import { reactive } from "vue";
|
import { watchEffect } from "vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
hotkey: GenericHotkey;
|
hotkey: GenericHotkey;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
let key = reactive(props.hotkey).key;
|
let key = "";
|
||||||
|
let isCtrl = false;
|
||||||
|
let isShift = false;
|
||||||
|
let isAlpha = false;
|
||||||
|
watchEffect(() => {
|
||||||
|
key = props.hotkey.key;
|
||||||
|
|
||||||
let isCtrl = key.startsWith("ctrl+");
|
isCtrl = key.startsWith("ctrl+");
|
||||||
if (isCtrl) key = key.slice(5);
|
if (isCtrl) {
|
||||||
|
key = key.slice(5);
|
||||||
|
}
|
||||||
|
|
||||||
let isShift = key.startsWith("shift+");
|
isShift = key.startsWith("shift+");
|
||||||
if (isShift) key = key.slice(6);
|
if (isShift) {
|
||||||
|
key = key.slice(6);
|
||||||
|
}
|
||||||
|
|
||||||
let isAlpha = key.length == 1 && key.toLowerCase() != key.toUpperCase();
|
isAlpha = key.length == 1 && key.toLowerCase() != key.toUpperCase();
|
||||||
if (isAlpha) key = key.toUpperCase();
|
if (isAlpha) {
|
||||||
|
key = key.toUpperCase();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
Loading…
Reference in a new issue