found the code and renamed things
This commit is contained in:
parent
4dad234532
commit
7557486b13
|
@ -22,6 +22,7 @@ import (
|
|||
// complicated console handling, it sends events here in a clean way.
|
||||
// This is equivalent to the linux command xev (apt install x11-utils)
|
||||
func gocuiEvent(g *gocui.Gui) error {
|
||||
me.ecount += 1
|
||||
mouseMove(g)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
|
||||
"github.com/awesome-gocui/gocui"
|
||||
log "go.wit.com/log"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
// this function uses the mouse position to highlight & unhighlight things
|
||||
|
@ -31,8 +32,20 @@ func mouseMove(g *gocui.Gui) {
|
|||
tk.dumpWidget("mouseMove()")
|
||||
}
|
||||
}
|
||||
if msgMouseDown {
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node == nil {
|
||||
log.Info("mouseMove() tk.node == nil")
|
||||
} else {
|
||||
if tk.node.WidgetType == widget.Stdout && msgMouseDown {
|
||||
moveMsg(g)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if mouseMoveOld(g) {
|
||||
if createStdout(g) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -56,32 +69,16 @@ func moveMsg(g *gocui.Gui) {
|
|||
g.SetViewOnBottom("msg")
|
||||
}
|
||||
|
||||
// this somehow is letting me drag around the stdout window
|
||||
func mouseMoveOld(g *gocui.Gui) bool {
|
||||
me.ecount += 1
|
||||
maxX, maxY := g.Size()
|
||||
mx, my := g.MousePosition()
|
||||
// log.Log(NOW, "handleEvent() START", maxX, maxY, mx, my, msgMouseDown)
|
||||
if _, err := g.View("msg"); msgMouseDown && err == nil {
|
||||
moveMsg(g)
|
||||
return true
|
||||
}
|
||||
func createStdout(g *gocui.Gui) bool {
|
||||
if widgetView, _ := g.View("msg"); widgetView == nil {
|
||||
log.Log(NOW, "handleEvent() create output widget now", maxX, maxY, mx, my)
|
||||
makeOutputWidget(g, "this is a create before a mouse click")
|
||||
if me.logStdout != nil {
|
||||
// setOutput(me.logStdout)
|
||||
// me.logStdout.Write("test out")
|
||||
w := me.logStdout.TK.(*guiWidget)
|
||||
msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount)
|
||||
w.Write([]byte(msg))
|
||||
// log.CaptureMode(w)
|
||||
log.Log(NOW, "logStdout test out")
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
log.Log(NOW, "output widget already exists", maxX, maxY, mx, my)
|
||||
}
|
||||
// log.Log(NOW, "handleEvent() END ", maxX, maxY, mx, my, msgMouseDown)
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue