summaryrefslogtreecommitdiff
path: root/action.go
diff options
context:
space:
mode:
Diffstat (limited to 'action.go')
-rw-r--r--action.go63
1 files changed, 41 insertions, 22 deletions
diff --git a/action.go b/action.go
index 25f780a..be97097 100644
--- a/action.go
+++ b/action.go
@@ -14,20 +14,26 @@ import (
// and that there already a widget created
func notNew(n *tree.Node) bool {
if n == nil {
- log.Warn("ready() n = nil")
+ log.Log(ERROR, "notNew() n = nil")
return true
}
if n.TK != nil {
- log.Warn("ready() n.TK = nil", n.WidgetId, n.GetProgName())
+ log.Log(ERROR, "notNew() n.TK = nil", n.WidgetId, n.GetProgName())
return true
}
if n.Parent == nil {
- log.Warn("ready() n.Parent = nil", n.WidgetId, n.GetProgName())
+ log.Log(ERROR, "notNew() n.Parent = nil", n.WidgetId, n.GetProgName())
return true
}
if n.Parent.TK == nil {
- log.Warn("ready() n.Parent.TK = nil", n.WidgetId, n.GetProgName())
- log.Warn("ready() n.Parent.TK = nil", n.Parent.WidgetId, n.Parent.GetProgName())
+ if n.Parent.WidgetId == 0 {
+ // this is normal if the widget type is a window
+ if n.WidgetType == widget.Window {
+ return true
+ }
+ }
+ log.Log(ERROR, "notNew() n.Parent.TK = nil", n.WidgetId, n.GetProgName())
+ log.Log(ERROR, "notNew() n.Parent.TK = nil", n.Parent.WidgetId, n.Parent.GetProgName())
return true
}
// this means you can add a new widgets
@@ -36,11 +42,11 @@ func notNew(n *tree.Node) bool {
func tkbad(n *tree.Node) bool {
if n == nil {
- log.Warn("ready() n = nil")
+ log.Log(ERROR, "tkbad() n = nil")
return true
}
if n.TK == nil {
- log.Warn("ready() n.TK = nil", n.WidgetId, n.GetProgName())
+ log.Log(ERROR, "tkbad() n.TK = nil", n.WidgetId, n.GetProgName())
return true
}
return false
@@ -49,20 +55,26 @@ func tkbad(n *tree.Node) bool {
// this makes sure widget and it's parent exists
func ready(n *tree.Node) bool {
if n == nil {
- log.Warn("ready() n = nil")
+ log.Log(ERROR, "ready() n = nil")
return false
}
if n.TK == nil {
- log.Warn("ready() n.TK = nil", n.WidgetId, n.GetProgName())
+ log.Log(ERROR, "ready() n.TK = nil", n.WidgetId, n.GetProgName())
return false
}
if n.Parent == nil {
- log.Warn("ready() n.Parent = nil", n.WidgetId, n.GetProgName())
+ log.Log(ERROR, "ready() n.Parent = nil", n.WidgetId, n.GetProgName())
return false
}
if n.Parent.TK == nil {
- log.Warn("ready() n.Parent.TK = nil", n.WidgetId, n.GetProgName())
- log.Warn("ready() n.Parent.TK = nil", n.Parent.WidgetId, n.Parent.GetProgName())
+ if n.Parent.WidgetId == 0 {
+ // this is normal if the widget type is a window
+ if n.WidgetType == widget.Window {
+ return false
+ }
+ }
+ log.Log(ERROR, "ready() n.Parent.TK = nil", n.WidgetId, n.GetProgName())
+ log.Log(ERROR, "ready() n.Parent.TK = nil", n.Parent.WidgetId, n.Parent.GetProgName())
return false
}
return true
@@ -112,7 +124,7 @@ func pad(n *tree.Node, b bool) {
if tkbad(n) {
return
}
- log.Warn("pad() on WidgetId =", n.WidgetId)
+ log.Log(ANDLABS, "pad() on WidgetId =", n.WidgetId)
t := n.TK.(*guiWidget)
if t == nil {
@@ -138,23 +150,25 @@ func pad(n *tree.Node, b bool) {
}
func widgetDelete(n *tree.Node) {
- log.Log(NOW, "widgetDelete()", n.WidgetId)
+ log.Log(ANDLABS, "widgetDelete()", n.WidgetId, n.WidgetType)
var tk *guiWidget
tk = n.TK.(*guiWidget)
if n.WidgetType == widget.Window {
- log.Warn("DESTROY uiWindow here")
- log.Warn("NEED TO REMOVE n from parent.Children")
+ log.Log(ANDLABS, "DESTROY uiWindow here")
+ log.Log(ANDLABS, "DESTROY NEED TO REMOVE n from parent.Children")
if tk.uiWindow != nil {
tk.uiWindow.Destroy()
tk.uiWindow = nil
}
n.DeleteNode()
+ } else {
+ log.Log(ANDLABS, "DESTROY can't destroy TODO:", n.WidgetId, n.WidgetType)
}
}
func processAction(a *widget.Action) {
- log.Warn("processAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
+ log.Log(ANDLABS, "processAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
if a.ActionType == widget.ToolkitInit {
Init()
@@ -166,13 +180,13 @@ func processAction(a *widget.Action) {
log.Log(INFO, "processAction() found the treeRoot")
me.treeRoot = me.myTree.AddNode(a)
} else {
- log.Warn("processAction() Something terrible has happened")
- log.Warn("processAction() treeNode was sent an action", a.ActionType, a)
+ log.Log(ERROR, "processAction() Something terrible has happened")
+ log.Log(ERROR, "processAction() treeNode was sent an action", a.ActionType, a)
}
return
}
- log.Warn("andlabs processAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId, a.ActionType)
+ log.Log(ANDLABS, "andlabs processAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId, a.ActionType)
switch a.WidgetType {
case widget.Flag:
log.Log(ERROR, "processAction() RE-IMPLEMENT LOG FLAGS")
@@ -197,6 +211,11 @@ func processAction(a *widget.Action) {
// this is normal. the widget is aleady deleted
return
}
+ if a.WidgetType == widget.Window {
+ // this could happen maybe someday
+ log.Log(ANDLABS, "processAction() trying on nonexistant window", a.WidgetId, a.ActionType)
+ return
+ }
log.Error(errors.New("andlabs processAction() ERROR findWidgetId found nil"), a.ActionType, a.WidgetType)
log.Log(NOW, "processAction() ERROR findWidgetId found nil for id =", a.WidgetId)
log.Log(NOW, "processAction() ERROR findWidgetId found nil", a.ActionType, a.WidgetType)
@@ -221,7 +240,7 @@ func processAction(a *widget.Action) {
case widget.Enable:
enable(n, true)
case widget.Disable:
- log.Warn("andlabs got disable for", n.WidgetId, n.State.ProgName)
+ log.Log(ANDLABS, "andlabs got disable for", n.WidgetId, n.State.ProgName)
enable(n, false)
case widget.Checked:
setChecked(n, a.State.Checked)
@@ -235,7 +254,7 @@ func processAction(a *widget.Action) {
case widget.Set:
setText(n, a)
case widget.SetText:
- log.Warn("andlabs SetText wid =", n.WidgetId, n.State.Value, a.State.Value)
+ log.Log(ANDLABS, "andlabs SetText wid =", n.WidgetId, n.State.Value, a.State.Value)
setText(n, a)
case widget.AddText:
addText(n, a)