summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.go30
-rw-r--r--event.go1
-rw-r--r--init.go13
-rw-r--r--structs.go14
4 files changed, 44 insertions, 14 deletions
diff --git a/common.go b/common.go
index 361c165..274877f 100644
--- a/common.go
+++ b/common.go
@@ -1,6 +1,7 @@
package tree
import (
+ "go.wit.com/log"
"go.wit.com/widget"
)
@@ -8,16 +9,35 @@ func (n *Node) GetProgName() string {
return n.State.ProgName
}
+/*
func (n *Node) GetValue() any {
return n.State.Value
}
+*/
func (n *Node) Bool() bool {
- return widget.GetBool(n.State.Value)
+ return false // widget.GetBool(n.State.Value)
}
func (n *Node) String() string {
- return widget.GetString(n.State.Value)
+ switch n.WidgetType {
+ case widget.Button:
+ return n.State.Label
+ case widget.Window:
+ return n.State.Label
+ case widget.Checkbox:
+ return n.State.Label
+ case widget.Group:
+ return n.State.Label
+ case widget.Label:
+ return n.State.Label
+ case widget.Dropdown:
+ return n.State.CurrentS
+ case widget.Combobox:
+ return n.State.CurrentS
+ }
+ log.Log(TREE, "do not know how to do String() on widget type", n.WidgetType)
+ return ""
}
func (n *Node) ProgName() string {
@@ -34,9 +54,15 @@ func (n *Node) GetText() string {
}
*/
+/*
func (n *Node) SetValue(a any) {
n.State.Value = a
}
+*/
+
+func (n *Node) SetCurrentS(s string) {
+ n.State.CurrentS = s
+}
func (n *Node) GetLabel() string {
return n.State.Label
diff --git a/event.go b/event.go
index 62b43c2..294fc54 100644
--- a/event.go
+++ b/event.go
@@ -93,7 +93,6 @@ func (me *TreeInfo) SendUserEvent(n *Node) {
}
var a widget.Action
a.WidgetId = n.WidgetId
- a.Value = n.State.Value
a.State = n.State
a.ActionType = widget.User
if n.WidgetType == widget.Checkbox {
diff --git a/init.go b/init.go
index f6951b0..c70b265 100644
--- a/init.go
+++ b/init.go
@@ -21,11 +21,16 @@ func (me *TreeInfo) newAction(a widget.Action) {
return
}
case widget.SetText:
+ log.Info("tree.SetText() a.State.CurrentS =", a.State.CurrentS)
+ log.Info("tree.SetText() a.State.DefaultS =", a.State.DefaultS)
+ log.Info("tree.SetText() a.State.NewString =", a.State.NewString)
switch n.WidgetType {
case widget.Dropdown:
- me.SetText(n, widget.GetString(a.State.Value))
+ me.SetText(n, a.State.NewString)
case widget.Combobox:
- me.SetText(n, widget.GetString(a.State.Value))
+ me.SetText(n, a.State.NewString)
+ case widget.Textbox:
+ me.SetText(n, a.State.NewString)
case widget.Window:
me.SetTitle(n, a.State.Label)
default:
@@ -35,9 +40,9 @@ func (me *TreeInfo) newAction(a widget.Action) {
case widget.AddText:
switch n.WidgetType {
case widget.Dropdown:
- me.AddText(n, widget.GetString(a.State.Value))
+ me.AddText(n, a.State.NewString)
case widget.Combobox:
- me.AddText(n, widget.GetString(a.State.Value))
+ me.AddText(n, a.State.NewString)
default:
log.Warn("AddText() not supported on widget", n.WidgetType, n.String())
}
diff --git a/structs.go b/structs.go
index 9465c70..e807e0d 100644
--- a/structs.go
+++ b/structs.go
@@ -11,7 +11,7 @@ import (
)
type TreeInfo struct {
- PluginName string
+ PluginName string
// this is the channel we send user events like
// mouse clicks or keyboard events back to the program
@@ -20,16 +20,16 @@ type TreeInfo struct {
// this is the channel we get requests to make widgets
pluginChan chan widget.Action
- treeRoot *Node
+ treeRoot *Node
// NodeI interface{}
// ActionFromChannel func(widget.Action)
NodeAction func(*Node, widget.ActionType)
- Add func(*Node)
- AddText func(*Node, string)
- SetText func(*Node, string)
- SetTitle func(*Node, string)
- SetLabel func(*Node, string)
+ Add func(*Node)
+ AddText func(*Node, string)
+ SetText func(*Node, string)
+ SetTitle func(*Node, string)
+ SetLabel func(*Node, string)
}
type Node struct {