summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/textbox.go
blob: cb6075d19ce0ab14c4942f45da67eb153112133d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main

import "git.wit.org/wit/gui/toolkit"

import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"

func (t andlabsT) NewTextbox(name string) *andlabsT {
	var newt andlabsT

	log(debugToolkit, "gui.Toolkit.NewTextbox()", name)
	if t.broken() {
		return nil
	}

	c := ui.NewNonWrappingMultilineEntry()
	newt.uiMultilineEntry = c

	newt.uiBox = t.uiBox
	newt.Name = name
	if (defaultBehavior) {
		t.uiBox.Append(c, true)
	} else {
		t.uiBox.Append(c, stretchy)
	}

	c.OnChanged(func(spin *ui.MultilineEntry) {
		newt.commonChange("Textbox")
	})

	return &newt
}

func NewTextbox(parentW *toolkit.Widget, w *toolkit.Widget) {
	var t, newt *andlabsT
	log(debugToolkit, "gui.andlabs.NewTextbox()", w.Name)

	t = mapToolkits[parentW]
	if (t == nil) {
		log(debugToolkit, "go.andlabs.NewTextbox() toolkit struct == nil. name=", parentW.Name, w.Name)
		return
	}

	if t.broken() {
		return
	}
	newt = new(andlabsT)

	newt.uiLabel = ui.NewLabel(w.Name)
	newt.uiBox = t.uiBox

	log(debugToolkit, "gui.Toolbox.NewTextbox() about to append to Box parent t:", w.Name)
	t.Dump()
	log(debugToolkit, "gui.Toolbox.NewTextbox() about to append to Box new t:", w.Name)
	newt.Dump()

	if (t.uiBox != nil) {
		t.uiBox.Append(newt.uiLabel, false)
	} else {
		log(debugToolkit, "ERROR: wit/gui andlabs couldn't place this Textbox in a box")
		return
	}

	mapWidgetsToolkits(w, newt)
}