Skip to content

Commit

Permalink
hide virtual keyboard when useHotkeys disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
TeemuKoivisto committed Mar 26, 2024
1 parent 5b6ca7f commit e7ac007
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/client/src/components/IOSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { inputsActions, inputs, midiInput } from '$stores/inputs'
import { reset, persist } from '$stores/persist'
import { keyboardActions } from '$stores/keyboard'
const hidden = persist(writable(false), { key: 'inputs-hidden' })
let fixedVelocity = $inputs.fixedVelocity ?? ''
Expand Down Expand Up @@ -42,6 +43,17 @@
fixedVelocity = $inputs.fixedVelocity || ''
}
}
function handleSetUseHotkeys(
e: Event & {
currentTarget: EventTarget & HTMLInputElement
}
) {
inputsActions.setInputValue('useHotkeys', e.currentTarget.checked)
if (!e.currentTarget.checked) {
setKeys = false
keyboardActions.cancelCapture()
}
}
function handleSetFadeTimeout(
e: Event & {
currentTarget: EventTarget & HTMLInputElement
Expand Down Expand Up @@ -134,7 +146,7 @@
id="hotkeys"
type="checkbox"
checked={$inputs.useHotkeys}
on:change={e => inputsActions.setInputValue('useHotkeys', e.currentTarget.checked)}
on:change={handleSetUseHotkeys}
/>
</div>
<div class="my-1 flex justify-between mr-12">
Expand All @@ -151,8 +163,10 @@
<div class="flex flex-col h-full">
<div class="h-[28px]">&nbsp;</div>
<div class="my-[2px] flex justify-between">
<button class="w-full btn-sm primary" on:click={() => (setKeys = !setKeys)}
>Set hotkeys</button
<button
class="w-full btn-sm primary"
disabled={!$inputs.useHotkeys}
on:click={() => (setKeys = !setKeys)}>Set hotkeys</button
>
</div>
<div class="my-1 flex justify-between">
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/stores/keyboard/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export const keyboardActions = {
}
return false
},
cancelCapture() {
capturingHotkeys.set(undefined)
captured.clear()
},
reset() {
keyboardOptions.set({
isCustom: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/client/src/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ html {
}
.primary {
@apply bg-blue-500 hover:bg-blue-700 text-white;
&:disabled {
@apply bg-gray-300 hover:bg-gray-300;
}
}
}

0 comments on commit e7ac007

Please sign in to comment.