summaryrefslogtreecommitdiff
path: root/dropdown.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-08 16:02:00 -0600
committerJeff Carr <[email protected]>2025-02-08 16:02:00 -0600
commit12d0e185ccc96d99c6d11d916797b0984c9fed68 (patch)
treec74743002bef31544fdf57d5d50926528ddfd1c1 /dropdown.go
parente80827d8904159f620a87823c2c032b28e14d1ec (diff)
text entry worked for the first time
Diffstat (limited to 'dropdown.go')
-rw-r--r--dropdown.go70
1 files changed, 54 insertions, 16 deletions
diff --git a/dropdown.go b/dropdown.go
index 85f2894..e8ebd04 100644
--- a/dropdown.go
+++ b/dropdown.go
@@ -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 {
// should only happen once
me.textbox.tk = makeNewFlagWidget(me.textbox.wId)
@@ -143,30 +160,51 @@ func (tk *guiWidget) showTextbox() {
log.Log(GOCUI, "showTextbox() Is Broken")
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.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.Show()
- me.textbox.active = true
- me.textbox.callerTK = tk
- r := me.textbox.tk.gocuiSize // set the 'full' size so that mouse clicks are sent here
- 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.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.callerTK = callertk
- me.textbox.tk.dumpWidget("showTextbox()")
+ tk.dumpWidget("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()
+ 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
me.textbox.callerTK.SetText(newname)