diff options
| author | Jeff Carr <[email protected]> | 2024-01-01 16:19:40 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-01 16:19:40 -0600 |
| commit | 7f6059a8e0f83bb4b450c1264195f08fe1280f05 (patch) | |
| tree | 0c75d2bbbab93c8611bc7ab466a6389485c645b5 /basicLabel.go | |
initial commit
Diffstat (limited to 'basicLabel.go')
| -rw-r--r-- | basicLabel.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/basicLabel.go b/basicLabel.go new file mode 100644 index 0000000..1cd6d3a --- /dev/null +++ b/basicLabel.go @@ -0,0 +1,60 @@ +/* + A Labeled label: + + ----------------------------- + | | | + | Food: | Apple | + | | | + ----------------------------- +*/ +package gadgets + +import ( + "go.wit.com/log" + "go.wit.com/gui/gui" +) + +type Node gui.Node + +type BasicLabel struct { + p *gui.Node // parent widget + l *gui.Node // label widget + v *gui.Node // value widget + + value string + label string + + Custom func() +} + +func (n *BasicLabel) Get() string { + return n.value +} + +func (n *BasicLabel) Set(value string) *BasicLabel { + log.Println("BasicLabel.Set() =", value) + if (n.v != nil) { + n.v.Set(value) + } + n.value = value + return n +} + +func (ngui *Node) NewBasicLabel(name string) *BasicLabel { + var n *gui.Node + n = (*gui.Node)(ngui) + d := BasicLabel { + p: n, + value: "", + } + + // various timeout settings + d.l = n.NewLabel(name) + d.v = n.NewLabel("") + d.v.Custom = func() { + d.value = d.v.S + log.Println("BasicLabel.Custom() user changed value to =", d.value) + } + + return &d +} |
