summaryrefslogtreecommitdiff
path: root/dropdown.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-08 16:23:03 -0600
committerJeff Carr <[email protected]>2025-02-08 16:23:03 -0600
commitf8b7c603a12513c3865bb3166f11133a444b89c7 (patch)
tree1ef0fb28d7433d56def73369d8b1c9694ef92d9f /dropdown.go
parent419f4aef6a3c4bda7fd85e69853b24d2bfb0469f (diff)
<enter> closes and saves the text from the textbox
Diffstat (limited to 'dropdown.go')
-rw-r--r--dropdown.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/dropdown.go b/dropdown.go
index 70aecb2..470a315 100644
--- a/dropdown.go
+++ b/dropdown.go
@@ -9,6 +9,7 @@ import (
"fmt"
"strings"
+ "github.com/awesome-gocui/gocui"
log "go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
@@ -186,14 +187,22 @@ func (callertk *guiWidget) showTextbox() {
me.baseGui.SetView(me.textbox.tk.cuiName, r.w0, r.h0, r.w1, r.h1, 0)
me.baseGui.SetCurrentView(me.textbox.tk.v.Name())
+ // bind the enter key to a function so we can close the textbox
+ me.baseGui.SetKeybinding(me.textbox.tk.v.Name(), gocui.KeyEnter, gocui.ModNone, theCloseTheTextbox)
+
me.textbox.active = true
me.textbox.callerTK = callertk
tk.dumpWidget("showTextbox()")
}
+func theCloseTheTextbox(g *gocui.Gui, v *gocui.View) error {
+ textboxClosed()
+ return nil
+}
+
// updates the text and sends an event back to the application
-func (tk *guiWidget) textboxClosed() {
+func textboxClosed() {
// get the text the user entered
newtext := "testing"
if me.textbox.tk.v == nil {
@@ -203,8 +212,9 @@ func (tk *guiWidget) textboxClosed() {
}
newtext = strings.TrimSpace(newtext)
me.textbox.active = false
- tk.Hide()
+ me.textbox.tk.Hide()
log.Info("textbox closed", newtext)
+
if me.clock.tk.v != nil {
me.baseGui.SetCurrentView("help")
} else {