2024-01-01 16:19:40 -06:00
|
|
|
/*
|
2024-01-18 05:04:18 -06:00
|
|
|
A Labeled Single Line Entry widget:
|
2024-01-01 16:19:40 -06:00
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
-----------------------------
|
|
|
|
| | |
|
|
|
|
| Food: | <type here> |
|
|
|
|
| | |
|
|
|
|
-----------------------------
|
2024-01-01 16:19:40 -06:00
|
|
|
*/
|
|
|
|
package gadgets
|
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
import (
|
|
|
|
"go.wit.com/gui"
|
2024-01-01 16:19:40 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type BasicEntry struct {
|
2024-01-18 05:04:18 -06:00
|
|
|
parent *gui.Node // parent widget
|
|
|
|
l *gui.Node // label widget
|
|
|
|
v *gui.Node // value widget
|
2024-01-01 16:19:40 -06:00
|
|
|
|
|
|
|
Custom func()
|
|
|
|
}
|
|
|
|
|
2024-01-18 17:32:49 -06:00
|
|
|
func (n *BasicEntry) SetText(s string) *BasicEntry {
|
|
|
|
log.Log(INFO, "BasicEntry.Set() =", s)
|
|
|
|
n.v.SetText(s)
|
2024-01-01 16:19:40 -06:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2024-01-10 20:04:51 -06:00
|
|
|
func (n *BasicEntry) Enable() {
|
|
|
|
log.Log(INFO, "BasicEntry.Enable()")
|
2024-01-18 17:32:49 -06:00
|
|
|
n.v.Enable()
|
2024-01-10 20:04:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (n *BasicEntry) Disable() {
|
|
|
|
log.Log(INFO, "BasicEntry.Disable()")
|
2024-01-18 17:32:49 -06:00
|
|
|
n.v.Disable()
|
2024-01-10 20:04:51 -06:00
|
|
|
}
|
|
|
|
|
2024-01-17 21:46:50 -06:00
|
|
|
func (n *BasicEntry) String() string {
|
|
|
|
log.Log(INFO, "BasicEntry.SetLabel() =", n.v.String())
|
|
|
|
return n.v.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *BasicEntry) SetLabel(s string) *BasicEntry {
|
|
|
|
n.l.SetText(s)
|
2024-01-10 20:04:51 -06:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2024-01-01 16:19:40 -06:00
|
|
|
func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
|
2024-01-18 05:04:18 -06:00
|
|
|
d := BasicEntry{
|
2024-01-01 16:19:40 -06:00
|
|
|
parent: p,
|
|
|
|
}
|
|
|
|
|
|
|
|
// various timeout settings
|
|
|
|
d.l = p.NewLabel(name)
|
|
|
|
d.v = p.NewEntryLine("")
|
|
|
|
d.v.Custom = func() {
|
2024-01-18 17:32:49 -06:00
|
|
|
log.Log(INFO, "BasicEntry() user changed =", d.String())
|
2024-01-10 20:04:51 -06:00
|
|
|
if d.Custom != nil {
|
|
|
|
d.Custom()
|
|
|
|
}
|
2024-01-01 16:19:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return &d
|
|
|
|
}
|