reworked hotkey handling - fixes #4355, fixes #4326, fixes #4340

This commit is contained in:
Eugene Pankov
2021-08-06 09:03:55 +02:00
parent 533837f5b7
commit 7b59ba4b73
6 changed files with 221 additions and 207 deletions

View File

@@ -1,7 +1,7 @@
import { Component, Input } from '@angular/core'
import { trigger, transition, style, animate } from '@angular/animations'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { HotkeysService, BaseComponent } from 'tabby-core'
import { HotkeysService, BaseComponent, Keystroke } from 'tabby-core'
const INPUT_TIMEOUT = 1000
@@ -36,7 +36,7 @@ const INPUT_TIMEOUT = 1000
],
})
export class HotkeyInputModalComponent extends BaseComponent {
@Input() value: string[] = []
@Input() value: Keystroke[] = []
@Input() timeoutProgress = 0
private lastKeyEvent: number|null = null
@@ -48,9 +48,9 @@ export class HotkeyInputModalComponent extends BaseComponent {
) {
super()
this.hotkeys.clearCurrentKeystrokes()
this.subscribeUntilDestroyed(hotkeys.key, (event) => {
this.subscribeUntilDestroyed(hotkeys.keystroke$, (keystroke) => {
this.lastKeyEvent = performance.now()
this.value = this.hotkeys.getCurrentKeySequence().map(x => x.value)
this.value.push(keystroke)
event.preventDefault()
event.stopPropagation()
})