tinkering

This commit is contained in:
Jeff Carr 2025-02-02 13:03:44 -06:00
parent f2a296064e
commit 676b3a8548
4 changed files with 31 additions and 13 deletions

View File

@ -57,13 +57,13 @@ func (n *Node) Hidden() bool {
} }
/* avoid this function name as confusing /* avoid this function name as confusing
func (n *Node) GetText() string { func (n *Node) GetText() string { // BAD
return widget.GetString(n.State.Value) return widget.GetString(n.State.Value)
} }
*/ */
/* /*
func (n *Node) SetValue(a any) { func (n *Node) SetValue(a any) { // BAD
n.State.Value = a n.State.Value = a
} }
*/ */

View File

@ -1,6 +1,8 @@
package tree package tree
import ( import (
"fmt"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/widget" "go.wit.com/widget"
) )
@ -20,7 +22,24 @@ func (n *Node) ShowButtons() {
} }
func (n *Node) DumpWidget(pad string) { func (n *Node) DumpWidget(pad string) {
log.Log(TREEWARN, "node:", pad, n.WidgetId, ",", n.WidgetType, ",", n.GetProgName()) s := n.GetProgName()
if s == "" {
s = n.CurrentS()
}
if s == "" {
s = n.String()
}
if s == "" {
s = n.ProgName()
}
if s == "" {
s = n.GetLabel()
}
if s == "" {
s = n.State.NewString
}
end := fmt.Sprintf("%d,%-9s .%s.", n.WidgetId, n.WidgetType, s)
log.Log(TREEWARN, "node:", pad, end)
} }
var depth int = 0 var depth int = 0

17
init.go
View File

@ -1,7 +1,10 @@
// Although most code from WIT.COM Inc is under the GPL
// This code is more generic because it must be able
// to be used in any GUI plugin
package tree package tree
import ( import (
"errors"
"os" "os"
"runtime/debug" "runtime/debug"
"sync" "sync"
@ -80,8 +83,8 @@ func (me *TreeInfo) newAction(a widget.Action) {
func (me *TreeInfo) catchActionChannel() { func (me *TreeInfo) catchActionChannel() {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
log.Log(TREEWARN, "YAHOOOO Recovered in tree.catchActionChannel()", r) log.Log(TREEWARN, "YAHOOOO. Recovered in tree.catchActionChannel()", r)
log.Log(TREEWARN, "YAHOOOO Recovered in tree.catchActionChannel() Plugin:", me.PluginName) log.Log(TREEWARN, "YAHOOOO. Recovered in tree.catchActionChannel() Plugin:", me.PluginName)
me.SendToolkitPanic() me.SendToolkitPanic()
debug.PrintStack() debug.PrintStack()
me.ToolkitClose() me.ToolkitClose()
@ -97,13 +100,7 @@ func (me *TreeInfo) catchActionChannel() {
case a := <-me.pluginChan: case a := <-me.pluginChan:
log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName) log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName)
muAction.Lock() muAction.Lock()
if me.newAction == nil { me.newAction(a)
log.Error(errors.New("toolkit newAction == nil"), a.WidgetId, a.ActionType, a.WidgetType)
} else {
// send this to the toolkit
me.newAction(a)
// me.ActionFromChannel(a)
}
muAction.Unlock() muAction.Unlock()
} }
} }

View File

@ -10,6 +10,8 @@ import (
"go.wit.com/widget" "go.wit.com/widget"
) )
// TODO: use protocol buffers
// this is the root node of the binary tree // this is the root node of the binary tree
// There is only one of these per application // There is only one of these per application
var treeRoot *Node var treeRoot *Node