mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Improve keyboard handling in main.go
This commit is contained in:
parent
ce7234179c
commit
f183a854c8
9
main.go
9
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 "/":
|
||||
|
Loading…
x
Reference in New Issue
Block a user