summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--action.go112
-rw-r--r--main.go7
2 files changed, 7 insertions, 112 deletions
diff --git a/action.go b/action.go
index 8cb749e..0ead8fd 100644
--- a/action.go
+++ b/action.go
@@ -168,118 +168,6 @@ func widgetDelete(n *tree.Node) {
}
}
-/*
-func processAction(a *widget.Action) {
- log.Log(ANDLABS, "processAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
-
- if a.ActionType == widget.ToolkitInit {
- Init()
- return
- }
- switch a.WidgetType {
- case widget.Root:
- if me.treeRoot == nil {
- log.Log(INFO, "processAction() found the treeRoot")
- me.treeRoot = me.myTree.AddNode(a)
- } else {
- log.Log(ERROR, "processAction() Something terrible has happened")
- log.Log(ERROR, "processAction() treeNode was sent an action", a.ActionType, a)
- }
- return
- }
-
- 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")
- return
- }
-
- if me.treeRoot == nil {
- panic("me.treeRoot == nil")
- }
-
- if a.ActionType == widget.Add {
- n := add(a)
- // show(n, !a.State.Hidden)
- if a.State.Hidden {
- hide(n)
- } else {
- if a.State.Enable {
- // nothing to do
- } else {
- enable(n, false)
- }
- }
- // pad(n, n.State.Pad)
- // expand(n, a.State.Expand)
- return
- }
-
- n := me.treeRoot.FindWidgetId(a.WidgetId)
- if n == nil {
- if a.ActionType == widget.Delete {
- // 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
- }
- str := a.ActionType.String() + " id " + widget.GetString(a.WidgetId) + " " + a.WidgetType.String()
- err := errors.New("andlabs processAction() findWidgetId got nil " + str)
- log.Error(err, a.ActionType, a.WidgetType)
- log.Log(WARN, "processAction() ERROR findWidgetId found nil for id =", a.WidgetId)
- log.Log(WARN, "processAction() ERROR findWidgetId found nil", a.ActionType, a.WidgetType)
- log.Log(WARN, "processAction() ERROR findWidgetId found nil for id =", a.WidgetId)
- if WARN.Bool() {
- me.treeRoot.ListWidgets()
- }
- return
- panic("findWidgetId found nil for id = " + string(a.WidgetId))
- }
-
- if a.ActionType == widget.Dump {
- log.Log(NOW, "processAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
- return
- }
-
- switch a.ActionType {
- case widget.Delete:
- widgetDelete(n)
- case widget.Show:
- show(n, true)
- case widget.Hide:
- hide(n)
- case widget.Enable:
- enable(n, true)
- case widget.Disable:
- log.Log(ANDLABS, "andlabs got disable for", n.WidgetId, n.State.ProgName)
- enable(n, false)
- case widget.Checked:
- setChecked(n, a.State.Checked)
- case widget.Get:
- setText(n, a)
- case widget.GetText:
- switch a.WidgetType {
- case widget.Textbox:
- a.Value = n.State.Value
- }
- case widget.Set:
- setText(n, a)
- case widget.SetText:
- log.Log(ANDLABS, "andlabs SetText wid =", n.WidgetId, n.State.Value, a.State.Value)
- setText(n, a)
- case widget.AddText:
- addText(n, a)
- default:
- log.Log(ERROR, "processAction() Unknown =", a.ActionType, a.WidgetType)
- }
- log.Log(INFO, "processAction() END =", a.ActionType, a.WidgetType)
-}
-*/
-
func SetTitle(n *tree.Node, s string) {
SetText(n, s)
}
diff --git a/main.go b/main.go
index 27e61cc..39b42f1 100644
--- a/main.go
+++ b/main.go
@@ -53,6 +53,12 @@ func queueAddText(n *tree.Node, s string) {
})
}
+func queueSetChecked(n *tree.Node, b bool) {
+ ui.QueueMain(func() {
+ setChecked(n, b)
+ })
+}
+
/*
func queueMain(currentA widget.Action) {
// this never happends
@@ -123,6 +129,7 @@ func init() {
me.myTree.SetLabel = queueSetLabel
me.myTree.SetText = queueSetText
me.myTree.AddText = queueAddText
+ me.myTree.SetChecked = queueSetChecked
// TODO: this is messed up. run ui.Main() from the first add? Initialize it with an empty thing first?
// fake out the OS toolkit by making a fake window. This is probably needed for macos & windows