parent
179dd22fe0
commit
530fbcc129
39
event.go
39
event.go
|
@ -16,9 +16,9 @@ import (
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (me *TreeInfo) DoEnableDebugger() {
|
func (me *TreeInfo) SendEnableDebugger() {
|
||||||
if me.callback == nil {
|
if me.callback == nil {
|
||||||
log.Warn("DoUserEvent() toolkit panic() callback == nil")
|
log.Warn("SendUserEvent() toolkit panic() callback == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var a widget.Action
|
var a widget.Action
|
||||||
|
@ -28,61 +28,64 @@ func (me *TreeInfo) DoEnableDebugger() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *TreeInfo) DoToolkitLoad(s string) {
|
func (me *TreeInfo) SendToolkitLoad(s string) {
|
||||||
if me.callback == nil {
|
if me.callback == nil {
|
||||||
log.Warn("DoUserEvent() toolkit load callback == nil")
|
log.Warn("SendUserEvent() toolkit load callback == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var a widget.Action
|
var a widget.Action
|
||||||
a.ActionType = widget.ToolkitLoad
|
a.ActionType = widget.ToolkitLoad
|
||||||
a.ProgName = me.PluginName
|
a.ProgName = me.PluginName
|
||||||
a.Value = s
|
a.Value = s
|
||||||
log.Warn("DoUserEvent() START: toolkit load", s)
|
log.Warn("SendUserEvent() START: toolkit load", s)
|
||||||
me.callback <- a
|
me.callback <- a
|
||||||
log.Warn("DoUserEvent() END: toolkit load", s)
|
log.Warn("SendUserEvent() END: toolkit load", s)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *TreeInfo) DoToolkitPanic() {
|
func (me *TreeInfo) SendToolkitPanic() {
|
||||||
if me.callback == nil {
|
if me.callback == nil {
|
||||||
log.Warn("DoUserEvent() toolkit panic() callback == nil")
|
log.Warn("SendUserEvent() toolkit panic() callback == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var a widget.Action
|
var a widget.Action
|
||||||
a.ActionType = widget.ToolkitPanic
|
a.ActionType = widget.ToolkitPanic
|
||||||
a.ProgName = me.PluginName
|
a.ProgName = me.PluginName
|
||||||
log.Info("DoUserEvent() START: toolkit panic()")
|
log.Info("SendUserEvent() START: toolkit panic()")
|
||||||
me.callback <- a
|
me.callback <- a
|
||||||
log.Info("DoUserEvent() END: toolkit panic()")
|
log.Info("SendUserEvent() END: toolkit panic()")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *TreeInfo) DoWindowCloseEvent(n *Node) {
|
func (me *TreeInfo) SendWindowCloseEvent(n *Node) {
|
||||||
if me.callback == nil {
|
if me.callback == nil {
|
||||||
log.Warn("DoUserEvent() callback == nil", n.WidgetId)
|
log.Warn("SendUserEvent() callback == nil", n.WidgetId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var a widget.Action
|
var a widget.Action
|
||||||
a.WidgetId = n.WidgetId
|
a.WidgetId = n.WidgetId
|
||||||
a.ActionType = widget.CloseWindow
|
a.ActionType = widget.CloseWindow
|
||||||
log.Info("DoUserEvent() START: user closed the window", n.GetProgName())
|
log.Info("SendUserEvent() START: user closed the window", n.GetProgName())
|
||||||
me.callback <- a
|
me.callback <- a
|
||||||
log.Info("DoUserEvent() END: user closed the window", n.GetProgName())
|
log.Info("SendUserEvent() END: user closed the window", n.GetProgName())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other goroutines must use this to access the GUI
|
// Other goroutines must use this to access the GUI
|
||||||
func (me *TreeInfo) DoUserEvent(n *Node) {
|
func (me *TreeInfo) SendUserEvent(n *Node) {
|
||||||
if me.callback == nil {
|
if me.callback == nil {
|
||||||
log.Warn("DoUserEvent() callback == nil", n.WidgetId)
|
log.Warn("SendUserEvent() callback == nil", n.WidgetId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var a widget.Action
|
var a widget.Action
|
||||||
a.WidgetId = n.WidgetId
|
a.WidgetId = n.WidgetId
|
||||||
a.Value = n.State.Value
|
a.Value = n.State.Value
|
||||||
a.ActionType = widget.User
|
a.ActionType = widget.User
|
||||||
log.Info("DoUserEvent() START: send a user event to the callback channel")
|
if n.WidgetType == widget.Checkbox {
|
||||||
|
log.Info("SendUserEvent() checkbox going to send:", a.Value)
|
||||||
|
}
|
||||||
|
log.Info("SendUserEvent() START: send a user event to the callback channel")
|
||||||
me.callback <- a
|
me.callback <- a
|
||||||
log.Info("DoUserEvent() END: sent a user event to the callback channel")
|
log.Info("SendUserEvent() END: sent a user event to the callback channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
16
init.go
16
init.go
|
@ -10,19 +10,11 @@ import (
|
||||||
|
|
||||||
var muAction sync.Mutex
|
var muAction sync.Mutex
|
||||||
|
|
||||||
func (me *TreeInfo) toolkit(a widget.Action) {
|
|
||||||
if me.ActionFromChannel == nil {
|
|
||||||
log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
me.ActionFromChannel(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (me *TreeInfo) catchActionChannel() {
|
func (me *TreeInfo) catchActionChannel() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
log.Warn(me.PluginName, "tree YAHOOOO Recovered in simpleStdin()", r)
|
log.Warn(me.PluginName, "tree YAHOOOO Recovered in simpleStdin()", r)
|
||||||
me.DoToolkitPanic()
|
me.SendToolkitPanic()
|
||||||
panic(-1)
|
panic(-1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -43,7 +35,11 @@ func (me *TreeInfo) catchActionChannel() {
|
||||||
*/
|
*/
|
||||||
muAction.Lock()
|
muAction.Lock()
|
||||||
// send this to the toolkit
|
// send this to the toolkit
|
||||||
me.toolkit(a)
|
if me.ActionFromChannel == nil {
|
||||||
|
log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType)
|
||||||
|
} else {
|
||||||
|
me.ActionFromChannel(a)
|
||||||
|
}
|
||||||
muAction.Unlock()
|
muAction.Unlock()
|
||||||
// log.Info("catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
// log.Info("catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue