need protobuf here

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-05 15:03:11 -06:00
parent 0f178bfaed
commit d92457087c
4 changed files with 44 additions and 14 deletions

View File

@ -1,6 +1,7 @@
package tree package tree
import ( import (
"go.wit.com/log"
"go.wit.com/widget" "go.wit.com/widget"
) )
@ -8,16 +9,35 @@ func (n *Node) GetProgName() string {
return n.State.ProgName return n.State.ProgName
} }
/*
func (n *Node) GetValue() any { func (n *Node) GetValue() any {
return n.State.Value return n.State.Value
} }
*/
func (n *Node) Bool() bool { func (n *Node) Bool() bool {
return widget.GetBool(n.State.Value) return false // widget.GetBool(n.State.Value)
} }
func (n *Node) String() string { 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 { func (n *Node) ProgName() string {
@ -34,9 +54,15 @@ func (n *Node) GetText() string {
} }
*/ */
/*
func (n *Node) SetValue(a any) { func (n *Node) SetValue(a any) {
n.State.Value = a n.State.Value = a
} }
*/
func (n *Node) SetCurrentS(s string) {
n.State.CurrentS = s
}
func (n *Node) GetLabel() string { func (n *Node) GetLabel() string {
return n.State.Label return n.State.Label

View File

@ -93,7 +93,6 @@ func (me *TreeInfo) SendUserEvent(n *Node) {
} }
var a widget.Action var a widget.Action
a.WidgetId = n.WidgetId a.WidgetId = n.WidgetId
a.Value = n.State.Value
a.State = n.State a.State = n.State
a.ActionType = widget.User a.ActionType = widget.User
if n.WidgetType == widget.Checkbox { if n.WidgetType == widget.Checkbox {

13
init.go
View File

@ -21,11 +21,16 @@ func (me *TreeInfo) newAction(a widget.Action) {
return return
} }
case widget.SetText: 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 { switch n.WidgetType {
case widget.Dropdown: case widget.Dropdown:
me.SetText(n, widget.GetString(a.State.Value)) me.SetText(n, a.State.NewString)
case widget.Combobox: 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: case widget.Window:
me.SetTitle(n, a.State.Label) me.SetTitle(n, a.State.Label)
default: default:
@ -35,9 +40,9 @@ func (me *TreeInfo) newAction(a widget.Action) {
case widget.AddText: case widget.AddText:
switch n.WidgetType { switch n.WidgetType {
case widget.Dropdown: case widget.Dropdown:
me.AddText(n, widget.GetString(a.State.Value)) me.AddText(n, a.State.NewString)
case widget.Combobox: case widget.Combobox:
me.AddText(n, widget.GetString(a.State.Value)) me.AddText(n, a.State.NewString)
default: default:
log.Warn("AddText() not supported on widget", n.WidgetType, n.String()) log.Warn("AddText() not supported on widget", n.WidgetType, n.String())
} }