summaryrefslogtreecommitdiff
path: root/basicCombobox.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-17 21:46:50 -0600
committerJeff Carr <[email protected]>2024-01-17 21:46:50 -0600
commit32fe455bb5c75b756ca0ff7e2a5d076a30978db4 (patch)
tree252a5e804d86d78a41cdca4f83b460baee71bfb3 /basicCombobox.go
parent751b6059c0432ede8de32656b777196cfdd6adaf (diff)
now should work without needed to actually displayv0.12.6
a nice improvement. actual toolkit widgets arent' actually needed. It's faster and can run in the dark autotypist compiles and runs Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'basicCombobox.go')
-rw-r--r--basicCombobox.go102
1 files changed, 16 insertions, 86 deletions
diff --git a/basicCombobox.go b/basicCombobox.go
index 4ca27bc..aacf612 100644
--- a/basicCombobox.go
+++ b/basicCombobox.go
@@ -12,32 +12,29 @@
package gadgets
import (
- "reflect"
- "strconv"
-
"go.wit.com/log"
"go.wit.com/gui/gui"
)
type BasicCombobox struct {
ready bool
- name string
+ progname string
parent *gui.Node // parent widget
l *gui.Node // label widget
d *gui.Node // dropdown widget
- value string
- label string
-
- values map[string]string
-
Custom func()
}
-func (d *BasicCombobox) Get() string {
+func (d *BasicCombobox) String() string {
if ! d.Ready() {return ""}
- return d.value
+ return d.d.String()
+}
+
+func (d *BasicCombobox) SetText(s string) {
+ if ! d.Ready() {return}
+ d.d.SetText(s)
}
// Returns true if the status is valid
@@ -64,95 +61,28 @@ func (d *BasicCombobox) SetTitle(name string) {
d.d.SetText(name)
}
-func (d *BasicCombobox) Add(value any) {
+func (d *BasicCombobox) AddText(s string) {
if ! d.Ready() {return}
- log.Log(INFO, "BasicCombobox.Add() =", value)
-
- var b reflect.Kind
- b = reflect.TypeOf(value).Kind()
-
- switch b {
- case reflect.Int:
- var i int
- i = value.(int)
- s := strconv.Itoa(i)
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- case reflect.String:
- s := value.(string)
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- case reflect.Bool:
- if value.(bool) == true {
- s := "true"
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- } else {
- s := "false"
- if d.values[s] != "added" {
- d.values[s] = "added"
- d.d.AddDropdownName(s)
- }
- }
- default:
- }
-}
-
-func (d *BasicCombobox) Set(value any) bool {
- if ! d.Ready() {return false}
- log.Log(INFO, "BasicCombobox.Set() =", value)
-
- var b reflect.Kind
- b = reflect.TypeOf(value).Kind()
-
- switch b {
- case reflect.Int:
- var i int
- i = value.(int)
- s := strconv.Itoa(i)
- d.d.SetText(s)
- d.value = s
- case reflect.String:
- d.d.SetText(value.(string))
- d.value = value.(string)
- case reflect.Bool:
- if value.(bool) == true {
- d.d.SetText("true")
- d.value = "true"
- } else {
- d.d.SetText("false")
- d.value = "false"
- }
- default:
- return false
- }
- return true
+ log.Log(INFO, "BasicCombobox.Add() =", s)
+ d.d.AddText(s)
}
-func NewBasicCombobox(p *gui.Node, name string) *BasicCombobox {
+func NewBasicCombobox(p *gui.Node, label string) *BasicCombobox {
d := BasicCombobox {
parent: p,
- name: name,
+ progname: label,
ready: false,
}
// various timeout settings
- d.l = p.NewLabel(name)
- d.d = p.NewCombobox("")
+ d.l = p.NewLabel(label)
+ d.d = p.NewCombobox()
d.d.Custom = func() {
- d.value = d.d.GetText()
- log.Warn("BasicCombobox.Custom() user changed value to =", d.value)
+ log.Warn("BasicCombobox.Custom() user changed value to =", d.d.String())
if d.Custom != nil {
d.Custom()
}
}
- d.values = make(map[string]string)
d.ready = true
return &d
}