trying to debug SetText()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-03 19:28:19 -06:00
parent 29d6cadbb3
commit fd56d89cc8
5 changed files with 20 additions and 55 deletions

View File

@ -15,10 +15,10 @@ func makeDropdownView(ddItems string) *guiWidget {
tk := newNode.TK.(*guiWidget)
tk.labelN = ddItems
tk.SetText(ddItems)
tk.gocuiSize.w0 = 20
tk.gocuiSize.w1 = 40
tk.gocuiSize.h0 = 10
tk.gocuiSize.h1 = 25
tk.gocuiSize.w0 = 100
tk.gocuiSize.w1 = 120
tk.gocuiSize.h0 = 15
tk.gocuiSize.h1 = 18
tk.v, _ = me.baseGui.SetView("ddview",
tk.gocuiSize.w0,
tk.gocuiSize.h0,
@ -31,7 +31,7 @@ func makeDropdownView(ddItems string) *guiWidget {
tk.v.Frame = true
tk.v.Clear()
fmt.Fprint(tk.v, ddItems)
tk.SetVisible(true)
tk.Show()
return tk
}
@ -135,6 +135,7 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
if me.dropdownW != nil {
log.Log(NOW, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.WidgetType)
me.dropdownW.SetText(items[itemNumber-1])
me.dropdownW.node.SetValue(items[itemNumber-1])
me.myTree.SendUserEvent(me.dropdownW.node)
}
}
@ -144,6 +145,10 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
}
func dropdownUnclicked(mouseX, mouseH int) {
if me.dropdownV == nil {
log.Log(NOW, "mouseUp() dropdownV = nil", mouseX, mouseH)
return
}
tk := me.dropdownV
log.Log(NOW, "mouseUp() view msgMouseDown (check here for dropdown menu click) (w,h) =", mouseX, mouseH)
log.Log(NOW, "mouseUp() ddview is the thing that was clicked", mouseX, mouseH)

View File

@ -66,9 +66,14 @@ func addDebugKeys(g *gocui.Gui) {
if showHelp {
helplayout()
showHelp = false
if me.dropdownV == nil {
me.dropdownV = makeDropdownView("addWidget() ddview")
}
me.dropdownV.Show()
} else {
me.baseGui.DeleteView("help")
showHelp = true
me.dropdownV.Hide()
}
return nil
})

View File

@ -80,6 +80,8 @@ func mainGogui() {
// allow gocui to close if possible, then print stack
log.Sleep(1)
me.myTree.SendToolkitLoad("nocui")
log.Sleep(3)
os.Stdout = origStdout
os.Stderr = origStderr
me.myTree.SendToolkitPanic()
@ -88,7 +90,6 @@ func mainGogui() {
// attempt to switch to the nocui toolkit
log.Sleep(1)
me.myTree.SendToolkitLoad("nocui")
// panic("BUMMER")
return
}

View File

@ -55,6 +55,8 @@ func (tk *guiWidget) Size() (int, int) {
}
}
return maxW + me.GroupPadW + 3, maxH
case widget.Label:
return len(tk.String()) + 2, 1
case widget.Checkbox:
return len(tk.String()) + 2, 3
}

50
view.go
View File

@ -49,7 +49,6 @@ func (w *guiWidget) textResize() bool {
}
func (w *guiWidget) hideView() {
// w.SetVisible(false)
w.deleteView()
}
@ -62,59 +61,12 @@ func (w *guiWidget) showView() {
}
log.Log(INFO, "showView() labelN =", w.labelN)
/*
if w.hidden {
w.SetVisible(false)
return
}
*/
if w.v != nil {
return
}
w.recreateView()
/*
w.textResize()
w.v.Clear()
fmt.Fprint(w.v, w.labelN)
/*
x0, y0, x1, y1, _ := me.baseGui.ViewPosition(w.cuiName)
// x0, y0, x1, y1, err := me.baseGui.ViewPosition(w.cuiName)
// log.Log(INFO, "showView() w.v already defined for widget", w.String(), x0, y0, x1, y1, err)
// n.smartGocuiSize()
// changed := w.textResize()
log.Log(INFO, "showView() Clear() and Fprint() here wId =", w.cuiName)
w.v.Clear()
fmt.Fprint(w.v, w.labelN)
log.Log(INFO, "showView() textResize() changed. Should recreateView here wId =", w.cuiName)
*/
/*
// if the gocui element has changed where it is supposed to be on the screen
// recreate it
if x0 != w.gocuiSize.w0 {
w.recreateView()
return
}
if y0 != w.gocuiSize.h0 {
log.Log(ERROR, "showView() start hight mismatch id=", w.cuiName, "gocui h vs computed h =", w.gocuiSize.h0, y0)
w.recreateView()
return
}
if x1 != w.gocuiSize.w1 {
log.Log(INFO, "showView() too wide", w.cuiName, "w,w", w.gocuiSize.w1, x1)
w.recreateView()
return
}
if y1 != w.gocuiSize.h1 {
log.Log(ERROR, "showView() too high", w.cuiName, "h,h", w.gocuiSize.h1, y1)
w.recreateView()
return
}
*/
// w.SetVisible(true)
}
// create or recreate the gocui widget visible