2024-01-01 16:19:40 -06:00
|
|
|
/*
|
|
|
|
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 {
|
2024-01-05 20:29:57 -06:00
|
|
|
log.Log(INFO, "BasicEntry.Set() =", value)
|
2024-01-01 16:19:40 -06:00
|
|
|
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
|
2024-01-05 20:29:57 -06:00
|
|
|
log.Log(INFO, "BasicEntry.Custom() user changed value to =", d.value)
|
2024-01-01 16:19:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return &d
|
|
|
|
}
|