/* A Labeled Single Line Entry widget: ----------------------------- | | | | Food: | | | | | ----------------------------- */ package gadgets import ( "go.wit.com/gui" "go.wit.com/log" ) type BasicEntry struct { parent *gui.Node // parent widget l *gui.Node // label widget v *gui.Node // value widget Custom func() } func (n *BasicEntry) SetText(s string) *BasicEntry { log.Log(GADGETS, "BasicEntry.Set() =", s) n.v.SetValue(s) n.v.SetText(s) n.v.SetLabel(s) return n } func (n *BasicEntry) Enable() { log.Log(GADGETS, "BasicEntry.Enable()") n.v.Enable() } func (n *BasicEntry) Disable() { log.Log(GADGETS, "BasicEntry.Disable()") n.v.Disable() } func (n *BasicEntry) String() string { log.Log(GADGETS, "BasicEntry.String() =", n.v.String()) return n.v.String() } func (n *BasicEntry) SetLabel(s string) *BasicEntry { n.l.SetText(s) return n } func NewBasicEntry(p *gui.Node, name string) *BasicEntry { d := BasicEntry{ parent: p, } // various timeout settings d.l = p.NewLabel(name) d.v = p.NewEntryLine("") d.v.Custom = func() { log.Log(GADGETS, "BasicEntry() user changed =", d.String()) if d.Custom != nil { d.Custom() } } return &d }