From f183a854c8cdc43ed4beed61b49ed7d1f36048f4 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 24 May 2019 16:56:44 -0700 Subject: [PATCH] Improve keyboard handling in main.go --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 7145d73b..f45f5706 100644 --- a/main.go +++ b/main.go @@ -40,22 +40,29 @@ func disableAllWidgets(widgets []wtf.Wtfable) { } func keyboardIntercept(event *tcell.EventKey) *tcell.EventKey { + // These keys are global keys used by the app. Widgets should not implement these keys switch event.Key() { case tcell.KeyCtrlR: refreshAllWidgets(runningWidgets) + return nil case tcell.KeyTab: focusTracker.Next() + return nil case tcell.KeyBacktab: focusTracker.Prev() + return nil case tcell.KeyEsc: focusTracker.None() + return nil } + // This function checks to see if any widget has been assigned the pressed key as its + // focus key if focusTracker.FocusOn(string(event.Rune())) { return nil } - // If no specific widget has focus, then allow key presses to fall through to the app + // If no specific widget has focus, then allow the key presses to fall through to the app if !focusTracker.IsFocused { switch string(event.Rune()) { case "/":