diff options
| author | Jeff Carr <[email protected]> | 2024-02-05 15:03:11 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-05 15:03:11 -0600 |
| commit | d92457087cb2bdb70c389699e5353187970336dc (patch) | |
| tree | 6d66039e1382dbbb24a14a0bd5fc54e95c9b43b5 | |
| parent | 0f178bfaed2962ad4b0e19c4590c346d4e68c5d4 (diff) | |
need protobuf herev0.20.0
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | common.go | 30 | ||||
| -rw-r--r-- | event.go | 1 | ||||
| -rw-r--r-- | init.go | 13 | ||||
| -rw-r--r-- | structs.go | 14 |
4 files changed, 44 insertions, 14 deletions
@@ -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 @@ -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 { @@ -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()) } @@ -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 { |
