part way to a generalized mouse move()

This commit is contained in:
Jeff Carr 2025-02-01 18:05:39 -06:00
parent 5a2097d080
commit f79cf89170
4 changed files with 1 additions and 32 deletions

View File

@ -23,10 +23,6 @@ func msgDown(g *gocui.Gui, v *gocui.View) error {
tk.dumpWidget("mouseDown()") tk.dumpWidget("mouseDown()")
} }
// debugging output
// log.Log(GOCUI, "msgDown() X,Y", initialMouseX, initialMouseY)
//
vx, vy, _, _, err := g.ViewPosition("msg") vx, vy, _, _, err := g.ViewPosition("msg")
if err == nil { if err == nil {
xOffset = initialMouseX - vx xOffset = initialMouseX - vx
@ -50,12 +46,6 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
if msgMouseDown { if msgMouseDown {
msgMouseDown = false msgMouseDown = false
if me.movingMsg {
me.movingMsg = false
return nil
} else {
g.DeleteView("msg")
}
} else if globalMouseDown { } else if globalMouseDown {
globalMouseDown = false globalMouseDown = false
g.DeleteView("globalDown") g.DeleteView("globalDown")
@ -63,8 +53,6 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
return nil return nil
} }
// func isMouseInMsg
// this is where you have to figure out what // this is where you have to figure out what
// widget was underneath so you can active // widget was underneath so you can active
// the right response for the toolkit user's app // the right response for the toolkit user's app

View File

@ -59,30 +59,12 @@ func mouseMove(g *gocui.Gui) {
// this is how the window gets dragged around // this is how the window gets dragged around
func (tk *guiWidget) moveNew(g *gocui.Gui) { func (tk *guiWidget) moveNew(g *gocui.Gui) {
mx, my := g.MousePosition() mx, my := g.MousePosition()
if !me.movingMsg && (mx != initialMouseX || my != initialMouseY) {
me.movingMsg = true
}
// tk.DrawAt(mx-xOffset, my-yOffset)
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0) g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0)
me.startOutputW = mx - xOffset me.startOutputW = mx - xOffset
me.startOutputH = my - yOffset me.startOutputH = my - yOffset
g.SetViewOnBottom("msg") g.SetViewOnBottom("msg")
} }
/*
// this is how the window gets dragged around
func moveMsg(g *gocui.Gui) {
mx, my := g.MousePosition()
if !me.movingMsg && (mx != initialMouseX || my != initialMouseY) {
me.movingMsg = true
}
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0)
me.startOutputW = mx - xOffset
me.startOutputH = my - yOffset
g.SetViewOnBottom("msg")
}
*/
func createStdout(g *gocui.Gui) bool { func createStdout(g *gocui.Gui) bool {
if widgetView, _ := g.View("msg"); widgetView == nil { if widgetView, _ := g.View("msg"); widgetView == nil {
makeOutputWidget(g, "this is a create before a mouse click") makeOutputWidget(g, "this is a create before a mouse click")

View File

@ -24,7 +24,7 @@ import (
var helpText []string = []string{"KEYBINDINGS", var helpText []string = []string{"KEYBINDINGS",
"", "",
"?: toggle help", "?: toggle zhelp",
"S: super mouse", "S: super mouse",
"M: list all widgets positions", "M: list all widgets positions",
"L: list all widgets in tree form", "L: list all widgets in tree form",

View File

@ -70,7 +70,6 @@ type config struct {
ecount int // counts how many mouse and keyboard events have occurred ecount int // counts how many mouse and keyboard events have occurred
supermouse bool // prints out every widget found while you move the mouse around supermouse bool // prints out every widget found while you move the mouse around
depth int // used for listWidgets() debugging depth int // used for listWidgets() debugging
movingMsg bool // means the user id dragging something around with the mouse
} }
// deprecate these // deprecate these