From 6045a205fde7457dcb20ed14139023a6f4afd222 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 8 Feb 2025 10:20:00 -0600 Subject: [PATCH] add 'Esc' key to close dropdown menu --- eventBindings.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/eventBindings.go b/eventBindings.go index b4bcf3e..ad6330f 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -29,6 +29,7 @@ func registerHandlers(g *gocui.Gui) { g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone, openDebuggger) // CTRL-D : open the (D)ebugger keyForced, modForced := gocui.MustParse("ctrl+z") // setup ctrl+z g.SetKeybinding("", keyForced, modForced, handle_ctrl_z) // CTRL-Z :cleverly let's you background gocui (breaks cursor mouse on return) + g.SetKeybinding("", gocui.KeyEsc, gocui.ModNone, doEsc) // escape key // regular keys g.SetKeybinding("", 'H', gocui.ModNone, theHelp) // 'H' toggles on and off the help menu @@ -122,6 +123,16 @@ func tabCycleWindows(g *gocui.Gui, v *gocui.View) error { return nil } +func doEsc(g *gocui.Gui, v *gocui.View) error { + log.Info("got escape key") + if me.dropdown.active { + me.dropdown.tk.Hide() + me.dropdown.active = false + log.Info("escaped from dropdown") + } + return nil +} + func theShow(g *gocui.Gui, v *gocui.View) error { var w *guiWidget w = me.treeRoot.TK.(*guiWidget)