diff --git a/size.go b/size.go index f0cff48..68dcf38 100644 --- a/size.go +++ b/size.go @@ -76,7 +76,7 @@ func (tk *guiWidget) Size() (int, int) { case widget.Label: return len(tk.String()) + 2, 1 case widget.Textbox: - return len(tk.String()) + 2, 3 // TODO: compute this based on 'window dense' + return len(tk.String()) + 10, 3 // TODO: compute this based on 'window dense' case widget.Checkbox: return len(tk.String()) + 2, 3 // TODO: compute this based on 'window dense' case widget.Button: diff --git a/textbox.go b/textbox.go index ecbba52..897602d 100644 --- a/textbox.go +++ b/textbox.go @@ -40,7 +40,7 @@ func (callertk *guiWidget) showTextbox() { return } - tk := me.textbox.tk + // tk := me.textbox.tk r := new(rectType) // startW, startH := tk.Position() r.w0 = callertk.gocuiSize.w0 + 4 @@ -48,7 +48,7 @@ func (callertk *guiWidget) showTextbox() { r.w1 = r.w0 + 24 r.h1 = r.h0 + 2 me.textbox.tk.forceSizes(r) - me.textbox.tk.dumpWidget("after sizes") + // me.textbox.tk.dumpWidget("after sizes") me.textbox.tk.Show() // actually makes the gocui view. TODO: redo this @@ -58,6 +58,10 @@ func (callertk *guiWidget) showTextbox() { } me.textbox.tk.setColorModal() + me.textbox.tk.v.Clear() + cur := strings.TrimSpace(callertk.String()) + log.Info("setting textbox string to:", cur) + me.textbox.tk.v.WriteString(cur) me.textbox.tk.v.Editable = true me.textbox.tk.v.Wrap = true @@ -71,7 +75,7 @@ func (callertk *guiWidget) showTextbox() { me.textbox.active = true me.textbox.callerTK = callertk - tk.dumpWidget("showTextbox()") + // tk.dumpWidget("showTextbox()") } func theCloseTheTextbox(g *gocui.Gui, v *gocui.View) error { @@ -82,7 +86,7 @@ func theCloseTheTextbox(g *gocui.Gui, v *gocui.View) error { // updates the text and sends an event back to the application func textboxClosed() { // get the text the user entered - newtext := "testing" + var newtext string if me.textbox.tk.v == nil { newtext = "" } else { @@ -91,7 +95,7 @@ func textboxClosed() { newtext = strings.TrimSpace(newtext) me.textbox.active = false me.textbox.tk.Hide() - log.Info("textbox closed", newtext) + log.Info("textbox closed with text:", newtext, me.textbox.callerTK.cuiName) if me.clock.tk.v != nil { me.baseGui.SetCurrentView("help") @@ -108,12 +112,12 @@ func textboxClosed() { win := me.textbox.callerTK.findParentWindow() if win != nil { - win.dumpWidget("redraw this!!!") + // win.dumpWidget("redraw this!!!") tk := me.textbox.callerTK - me.textbox.callerTK.dumpWidget("resize this!!!") + // me.textbox.callerTK.dumpWidget("resize this!!!") me.textbox.callerTK.Size() me.textbox.callerTK.placeWidgets(tk.gocuiSize.w0-4, tk.gocuiSize.h0-4) - tk.dumpWidget("resize:" + tk.String()) + // tk.dumpWidget("resize:" + tk.String()) win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0) } } diff --git a/treeAdd.go b/treeAdd.go index 35f3514..d20da80 100644 --- a/treeAdd.go +++ b/treeAdd.go @@ -77,8 +77,8 @@ func addWidget(n *tree.Node) { tk.setColorInput() return case widget.Textbox: - n.State.Label = "TEXTBOX" - tk.labelN = " " + n.State.Label + n.State.Label = "" + tk.labelN = " " tk.color = &colorDropdown return case widget.Combobox: diff --git a/treeWidget.go b/treeWidget.go index 166cb77..2c3f5b2 100644 --- a/treeWidget.go +++ b/treeWidget.go @@ -79,6 +79,10 @@ func (tk *guiWidget) String() string { if curval != "" { return curval } + curval = tk.GetText() + if curval != "" { + return curval + } curval = tk.node.String() if curval != "" { return curval diff --git a/view.go b/view.go index b518d59..d9ec8a6 100644 --- a/view.go +++ b/view.go @@ -23,6 +23,13 @@ func (tk *guiWidget) textResize() { h += 1 } + // todo: fix all this old code + if tk.node.WidgetType == widget.Textbox { + if w < 5 { + w = 5 + } + } + // this is old code. now move this somewhere smarter tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW // TODO: move this FramePadW out of here tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH // TODO: fix this size computation