text entry worked for the first time

This commit is contained in:
Jeff Carr 2025-02-08 16:02:00 -06:00
parent e80827d890
commit 12d0e185cc
1 changed files with 54 additions and 16 deletions

View File

@ -133,7 +133,24 @@ func dropdownUnclicked(w, h int) {
} }
*/ */
func (tk *guiWidget) showTextbox() { func (tk *guiWidget) forceSizes(r *rectType) {
tk.gocuiSize.w0 = r.w0
tk.gocuiSize.w1 = r.w1
tk.gocuiSize.h0 = r.h0
tk.gocuiSize.h1 = r.h1
tk.full.w0 = r.w0
tk.full.w1 = r.w1
tk.full.h0 = r.h0
tk.full.h1 = r.h1
tk.force.w0 = r.w0
tk.force.w1 = r.w1
tk.force.h0 = r.h0
tk.force.h1 = r.h1
}
func (callertk *guiWidget) showTextbox() {
if me.textbox.tk == nil { if me.textbox.tk == nil {
// should only happen once // should only happen once
me.textbox.tk = makeNewFlagWidget(me.textbox.wId) me.textbox.tk = makeNewFlagWidget(me.textbox.wId)
@ -143,30 +160,51 @@ func (tk *guiWidget) showTextbox() {
log.Log(GOCUI, "showTextbox() Is Broken") log.Log(GOCUI, "showTextbox() Is Broken")
return return
} }
startW, startH := tk.Position()
me.textbox.tk.MoveToOffset(startW+3, startH+2) tk := me.textbox.tk
r := new(rectType)
// startW, startH := tk.Position()
r.w0 = 50
r.h0 = 20
r.w1 = r.w0 + 24
r.h1 = r.h0 + 2
me.textbox.tk.forceSizes(r)
me.textbox.tk.dumpWidget("after sizes")
me.textbox.tk.labelN = "holy cow" me.textbox.tk.labelN = "holy cow"
me.textbox.tk.Show() // actually makes the gocui view. TODO: redo this
if me.textbox.tk.v == nil {
log.Info("wtf went wrong")
return
}
me.textbox.tk.setColorModal() me.textbox.tk.setColorModal()
me.textbox.tk.Show()
me.textbox.tk.v.Editable = true
me.textbox.tk.v.Wrap = true
me.baseGui.SetView(me.textbox.tk.cuiName, r.w0, r.h0, r.w1, r.h1, 0)
me.baseGui.SetCurrentView(me.textbox.tk.v.Name())
me.textbox.active = true me.textbox.active = true
me.textbox.callerTK = tk me.textbox.callerTK = callertk
r := me.textbox.tk.gocuiSize // set the 'full' size so that mouse clicks are sent here tk.dumpWidget("showTextbox()")
me.textbox.tk.full.w0 = r.w0
me.textbox.tk.full.w1 = r.w1
me.textbox.tk.full.h0 = r.h0
me.textbox.tk.full.h1 = r.h1
me.textbox.tk.dumpWidget("showTextbox()")
} }
// updates the text and sends an event back to the application // updates the text and sends an event back to the application
func (tk *guiWidget) textboxClosed() { func (tk *guiWidget) textboxClosed() {
tk.Hide()
me.textbox.active = false
// get the text the user entered // get the text the user entered
newname := tk.GetText() newname := "testing"
if me.textbox.tk.v == nil {
newname = "wtf"
} else {
newname = me.textbox.tk.v.ViewBuffer()
}
me.textbox.active = false
tk.Hide()
log.Info("textbox closed", newname)
// change the text of the caller widget // change the text of the caller widget
me.textbox.callerTK.SetText(newname) me.textbox.callerTK.SetText(newname)