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 {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "BasicEntry.Set() =", s)
|
2024-01-24 02:27:52 -06:00
|
|
|
n.v.SetValue(s)
|
2024-01-18 17:32:49 -06:00
|
|
|
n.v.SetText(s)
|
2024-01-24 02:27:52 -06:00
|
|
|
n.v.SetLabel(s)
|
2024-01-01 16:19:40 -06:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2024-01-10 20:04:51 -06:00
|
|
|
func (n *BasicEntry) Enable() {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "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() {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "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 {
|
2024-01-24 02:27:52 -06:00
|
|
|
log.Log(GADGETS, "BasicEntry.String() =", n.v.String())
|
2024-01-17 21:46:50 -06:00
|
|
|
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-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "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
|
|
|
|
}
|