<enter> closes and saves the text from the textbox
This commit is contained in:
parent
419f4aef6a
commit
f8b7c603a1
14
dropdown.go
14
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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue