change keybind test

This commit is contained in:
PandaDEV 2024-08-27 17:15:37 +10:00
parent 0b077a9b2e
commit ebf6e0311f
No known key found for this signature in database
GPG key ID: 13EFF9BAF70EE75C
8 changed files with 780 additions and 531 deletions

53
pages/keybind.vue Normal file
View file

@ -0,0 +1,53 @@
<template>
<div class="bg">
<div class="keybind-container">
<h2>Set New Keybind</h2>
<div
class="keybind-input"
tabindex="0"
@focus="startCapture"
@blur="stopCapture"
ref="keybindInput"
>
{{ currentKeybind || 'Click here, then press your desired key combination' }}
</div>
<button @click="saveKeybind" :disabled="!currentKeybind">Save Keybind</button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import { invoke } from '@tauri-apps/api/core';
import { listen } from '@tauri-apps/api/event';
const currentKeybind = ref('');
const keybindInput = ref<HTMLElement | null>(null);
const startCapture = async () => {
await invoke('start_keybind_capture');
};
const stopCapture = async () => {
await invoke('stop_keybind_capture');
};
const saveKeybind = () => {
console.log('Saving keybind:', currentKeybind.value);
// Implement saving logic here
};
onMounted(async () => {
const unlisten = await listen('keybind_captured', (event: any) => {
currentKeybind.value = event.payload as string;
});
onUnmounted(() => {
unlisten();
});
});
</script>
<style lang="scss">
@import '~/assets/css/keybind.scss';
</style>