From d37197f45bc1e9d5095bc2edc86d28071a6b34ae Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 14 Apr 2022 17:15:40 +0200 Subject: [PATCH] app: give key handlers a chance to process Tab and Shift-Tab Before this change, Tab and Shift-Tab would always result in focus movement. This this change, a key.InputOp with a matching Keys set will block focus movement and deliver the events to it. Signed-off-by: Elias Naur --- app/window.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/window.go b/app/window.go index 88d2ff84..12d156fa 100644 --- a/app/window.go +++ b/app/window.go @@ -842,16 +842,16 @@ func (w *Window) processEvent(d driver, e event.Event) { e2.Config.Size = e2.Config.Size.Sub(w.decorations.size) w.out <- e2 case event.Event: - // Convert tab or shift+tab presses to focus moves. - if e, ok := e.(key.Event); ok && e.State == key.Press && e.Name == key.NameTab && e.Modifiers&^key.ModShift == 0 { - dir := router.FocusForward - if e.Modifiers.Contain(key.ModShift) { - dir = router.FocusBackward - } - w.moveFocus(dir, d) - } else if w.queue.q.Queue(e2) { + if w.queue.q.Queue(e2) { w.setNextFrame(time.Time{}) w.updateAnimation(d) + } else if e, ok := e.(key.Event); ok && e.State == key.Press { + switch { + case e.Name == key.NameTab && e.Modifiers == 0: + w.moveFocus(router.FocusForward, d) + case e.Name == key.NameTab && e.Modifiers == key.ModShift: + w.moveFocus(router.FocusBackward, d) + } } w.updateCursor(d) }