blob: e95d17d6ae4ea04ecf619bdaffe0672b7507f742 (
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
|
/*
A Labeled Single Line Entry widget:
-----------------------------
| | |
| Food: | <type here> |
| | |
-----------------------------
*/
package gadgets
import (
"go.wit.com/log"
"go.wit.com/gui/gui"
)
type BasicEntry struct {
parent *gui.Node // parent widget
l *gui.Node // label widget
v *gui.Node // value widget
value string
label string
Custom func()
}
func (n *BasicEntry) Get() string {
return n.value
}
func (n *BasicEntry) Set(value string) *BasicEntry {
log.Println("BasicEntry.Set() =", value)
if (n.v != nil) {
n.v.Set(value)
}
n.value = value
return n
}
func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
d := BasicEntry {
parent: p,
value: "",
}
// various timeout settings
d.l = p.NewLabel(name)
d.v = p.NewEntryLine("")
d.v.Custom = func() {
d.value = d.v.S
log.Println("BasicEntry.Custom() user changed value to =", d.value)
}
return &d
}
|