diff options
| -rw-r--r-- | dropdown.go | 14 | ||||
| -rw-r--r-- | eventBindings.go | 2 | ||||
| -rw-r--r-- | eventMouse.go | 2 | ||||
| -rw-r--r-- | eventMouseClick.go | 2 |
4 files changed, 15 insertions, 5 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 { diff --git a/eventBindings.go b/eventBindings.go index 1c0e6cc..cb80a0f 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -70,7 +70,7 @@ func theSuperMouse(g *gocui.Gui, v *gocui.View) error { // use this to test code ideas // put whatever you want here and hit '2' to activate it func theNotsure(g *gocui.Gui, v *gocui.View) error { - log.Info("got keypress 2. now what? dark =", me.dark) + log.Info("got to theNotsure(). now what? dark =", me.dark) return nil } diff --git a/eventMouse.go b/eventMouse.go index ff973c4..088f2e0 100644 --- a/eventMouse.go +++ b/eventMouse.go @@ -82,7 +82,7 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error { for _, tk := range findByXY(w, h) { if (tk.node.WidgetType == widget.Flag) && (tk == me.textbox.tk) { me.textbox.active = false - tk.textboxClosed() + textboxClosed() return nil } } diff --git a/eventMouseClick.go b/eventMouseClick.go index dcf394a..dcda9fd 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -122,7 +122,7 @@ func doMouseClick(w int, h int) { } if tk.node.WidgetId == me.textbox.wId { log.Info("got textbox click", w, h, tk.cuiName) - tk.textboxClosed() + textboxClosed() return } } |
