textbox opens

This commit is contained in:
Jeff Carr 2025-02-08 10:30:19 -06:00
parent 6045a205fd
commit ed024aac70
3 changed files with 23 additions and 1 deletions

View File

@ -150,6 +150,7 @@ func (tk *guiWidget) showTextbox() {
// updates the text and sends an event back to the application
func (tk *guiWidget) textboxClosed() {
tk.Hide()
me.textbox.active = false
// get the text the user entered
newname := tk.GetText()

View File

@ -130,6 +130,11 @@ func doEsc(g *gocui.Gui, v *gocui.View) error {
me.dropdown.active = false
log.Info("escaped from dropdown")
}
if me.textbox.active {
me.textbox.tk.Hide()
me.textbox.active = false
log.Info("escaped from textbox")
}
return nil
}

View File

@ -120,6 +120,10 @@ func doMouseClick(w int, h int) {
log.Info("got dropdwon click", w, h, tk.cuiName)
tk.dropdownClicked(w, h)
}
if tk.node.WidgetId == me.textbox.wId {
log.Info("got textbox click", w, h, tk.cuiName)
tk.textboxClosed()
}
}
return
}
@ -127,6 +131,17 @@ func doMouseClick(w int, h int) {
// priority widgets. send the click here first
for _, tk := range findByXY(w, h) {
switch tk.node.WidgetType {
case widget.Checkbox:
if tk.node.State.Checked {
log.Log(WARN, "checkbox is being set to false")
tk.node.State.Checked = false
tk.setCheckbox()
} else {
log.Log(WARN, "checkbox is being set to true")
tk.node.State.Checked = true
tk.setCheckbox()
}
me.myTree.SendUserEvent(tk.node)
case widget.Button:
me.myTree.SendFromUser(tk.node)
return
@ -140,7 +155,8 @@ func doMouseClick(w int, h int) {
tk.showTextbox()
return
default:
tk.dumpWidget("undef click()")
// TODO: enable the GUI debugger in gocui
// tk.dumpWidget("undef click()") // enable this to debug widget clicks
}
}