2024-01-01 16:19:40 -06:00
|
|
|
/*
|
2024-01-18 05:04:18 -06:00
|
|
|
A Labeled label:
|
2024-01-01 16:19:40 -06:00
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
-----------------------------
|
|
|
|
| | |
|
|
|
|
| Food: | Apple |
|
|
|
|
| | |
|
|
|
|
-----------------------------
|
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 Node gui.Node
|
|
|
|
|
|
|
|
type BasicLabel struct {
|
2024-01-18 05:04:18 -06:00
|
|
|
p *gui.Node // parent widget
|
|
|
|
l *gui.Node // label widget
|
|
|
|
v *gui.Node // value widget
|
2024-01-01 16:19:40 -06:00
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
value string
|
|
|
|
label string
|
2024-01-01 16:19:40 -06:00
|
|
|
|
|
|
|
Custom func()
|
|
|
|
}
|
|
|
|
|
2024-01-17 21:46:50 -06:00
|
|
|
/*
|
2024-01-01 16:19:40 -06:00
|
|
|
func (n *BasicLabel) Get() string {
|
|
|
|
return n.value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *BasicLabel) Set(value string) *BasicLabel {
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "BasicLabel.Set() =", value)
|
2024-01-01 16:19:40 -06:00
|
|
|
if (n.v != nil) {
|
|
|
|
n.v.Set(value)
|
|
|
|
}
|
|
|
|
n.value = value
|
|
|
|
return n
|
|
|
|
}
|
2024-01-17 21:46:50 -06:00
|
|
|
*/
|
2024-01-01 16:19:40 -06:00
|
|
|
|
|
|
|
func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
|
|
|
|
var n *gui.Node
|
|
|
|
n = (*gui.Node)(ngui)
|
2024-01-18 05:04:18 -06:00
|
|
|
d := BasicLabel{
|
|
|
|
p: n,
|
2024-01-01 16:19:40 -06:00
|
|
|
value: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
// various timeout settings
|
|
|
|
d.l = n.NewLabel(name)
|
|
|
|
d.v = n.NewLabel("")
|
|
|
|
d.v.Custom = func() {
|
2024-01-17 21:46:50 -06:00
|
|
|
d.value = d.v.String()
|
2024-01-21 11:42:31 -06:00
|
|
|
log.Log(GADGETS, "BasicLabel.Custom() user changed value to =", d.value)
|
2024-01-01 16:19:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return &d
|
|
|
|
}
|