debian/nocui/action.go

90 lines
2.1 KiB
Go
Raw Normal View History

2024-01-01 16:11:54 -06:00
package main
/*
a simple function to handle widget actions
You can tie this into your toolkit here.
*/
2024-01-01 16:11:54 -06:00
import (
"go.wit.com/log"
"go.wit.com/gui/widget"
// "go.wit.com/gui/toolkits/tree"
2024-01-01 16:11:54 -06:00
)
func doAction(a widget.Action) {
log.Log(INFO, "doAction() START a.ActionType =", a.ActionType)
log.Log(INFO, "doAction() START a.ProgName =", a.ProgName)
2024-01-01 16:11:54 -06:00
if (a.ActionType == widget.ToolkitInit) {
2024-01-01 16:11:54 -06:00
return
}
log.Log(INFO, "doAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId)
2024-01-01 16:11:54 -06:00
switch a.WidgetType {
case widget.Root:
me.treeRoot = me.myTree.AddNode(&a)
log.Log(INFO, "doAction() found treeRoot")
2024-01-01 16:11:54 -06:00
return
}
switch a.ActionType {
case widget.Add:
me.myTree.AddNode(&a)
2024-01-01 16:11:54 -06:00
return
}
n := me.treeRoot.FindWidgetId(a.WidgetId)
if n == nil {
log.Warn("FindId() n == nil", a.WidgetId, a.ActionType)
log.Warn("FindId() n == nil", a.WidgetId, a.ActionType)
log.Warn("FindId() n == nil", a.WidgetId, a.ActionType)
log.Warn("Aaaaa!, return")
return
}
2024-01-01 16:11:54 -06:00
switch a.ActionType {
case widget.Show:
n.State.Visable = true
case widget.Hide:
n.State.Visable = false
case widget.Enable:
n.State.Visable = true
case widget.Disable:
n.State.Visable = false
case widget.Get:
log.Warn("value =", n.State.Value)
case widget.GetText:
log.Warn("value =", n.String())
case widget.Set:
n.State.Value = a.State.Value
case widget.SetText:
log.Warn("GOT TO SetText()", a.WidgetId)
log.Warn("GOT TO SetText()", a.WidgetId)
log.Warn("GOT TO SetText()", a.WidgetId)
log.Warn("GOT TO SetText()", a.WidgetId)
if n == nil {
log.Warn("HOT DIGGITY. n == nil")
}
n.State.Value = a.State.Value
case widget.AddText:
n.State.Strings = append(a.State.Strings, widget.GetString(a.State.Value))
case widget.Margin:
n.State.Pad = true
case widget.Unmargin:
n.State.Pad = false
case widget.Pad:
n.State.Pad = true
case widget.Unpad:
n.State.Pad = false
case widget.Delete:
log.Warn("doAction() TODO: Delete()")
// n.Delete()
case widget.Move:
log.Warn("doAction() TODO: Move()")
2024-01-01 16:11:54 -06:00
default:
log.Log(ERROR, "doAction() Unknown =", a.ActionType, a.WidgetType)
2024-01-01 16:11:54 -06:00
}
log.Log(INFO, "doAction() END =", a.ActionType, a.WidgetType)
2024-01-01 16:11:54 -06:00
}