summaryrefslogtreecommitdiff
path: root/basicEntry.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-01 16:19:40 -0600
committerJeff Carr <[email protected]>2024-01-01 16:19:40 -0600
commit7f6059a8e0f83bb4b450c1264195f08fe1280f05 (patch)
tree0c75d2bbbab93c8611bc7ab466a6389485c645b5 /basicEntry.go
initial commit
Diffstat (limited to 'basicEntry.go')
-rw-r--r--basicEntry.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/basicEntry.go b/basicEntry.go
new file mode 100644
index 0000000..e95d17d
--- /dev/null
+++ b/basicEntry.go
@@ -0,0 +1,56 @@
+/*
+ A Labeled Single Line Entry widget:
+
+ -----------------------------
+ | | |
+ | Food: | <type here> |
+ | | |
+ -----------------------------
+*/
+package gadgets
+
+import (
+ "go.wit.com/log"
+ "go.wit.com/gui/gui"
+)
+
+type BasicEntry struct {
+ parent *gui.Node // parent widget
+ l *gui.Node // label widget
+ v *gui.Node // value widget
+
+ value string
+ label string
+
+ Custom func()
+}
+
+func (n *BasicEntry) Get() string {
+ return n.value
+}
+
+func (n *BasicEntry) Set(value string) *BasicEntry {
+ log.Println("BasicEntry.Set() =", value)
+ if (n.v != nil) {
+ n.v.Set(value)
+ }
+ n.value = value
+ return n
+}
+
+func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
+ d := BasicEntry {
+ parent: p,
+ value: "",
+ }
+
+ // various timeout settings
+ d.l = p.NewLabel(name)
+ d.v = p.NewEntryLine("")
+ d.v.Custom = func() {
+ d.value = d.v.S
+ log.Println("BasicEntry.Custom() user changed value to =", d.value)
+ }
+
+ return &d
+}