need protobuf here
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0f178bfaed
commit
d92457087c
30
common.go
30
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
|
||||
|
|
1
event.go
1
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 {
|
||||
|
|
13
init.go
13
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())
|
||||
}
|
||||
|
|
14
structs.go
14
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 {
|
||||
|
|
Loading…
Reference in New Issue