removed old var
This commit is contained in:
parent
1010db44a6
commit
a6c1864f43
|
@ -21,7 +21,7 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
|||
*/
|
||||
|
||||
me.mouse.mouseUp = true
|
||||
me.mouse.globalMouseDown = false
|
||||
// me.mouse.globalMouseDown = false
|
||||
me.mouse.currentDrag = nil
|
||||
|
||||
if me.mouse.double && (time.Since(me.mouse.down) < me.mouse.doubletime) {
|
||||
|
@ -45,7 +45,7 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
|||
if time.Since(me.mouse.down) < me.mouse.doubletime {
|
||||
me.mouse.double = true
|
||||
}
|
||||
me.mouse.globalMouseDown = true
|
||||
// me.mouse.globalMouseDown = true
|
||||
me.mouse.mouseUp = false
|
||||
me.mouse.down = time.Now()
|
||||
w, h := g.MousePosition()
|
||||
|
|
|
@ -42,6 +42,8 @@ func mouseMove(g *gocui.Gui) {
|
|||
// can't drag or do anything when dropdown or textbox are visible
|
||||
return
|
||||
}
|
||||
// okay, the mouse is down and it has been long enough
|
||||
// the user is trying to drag something. let's figure out what
|
||||
|
||||
w, h := g.MousePosition()
|
||||
// toggle off all highlight vies except for whatever is under the mouse
|
||||
|
@ -61,60 +63,64 @@ func mouseMove(g *gocui.Gui) {
|
|||
return
|
||||
}
|
||||
|
||||
if me.mouse.globalMouseDown && (me.dropdown.active || me.textbox.active) {
|
||||
log.Info("can't drag while dropdown or textbox are active", w, h)
|
||||
/*
|
||||
if me.mouse.globalMouseDown && (me.dropdown.active || me.textbox.active) {
|
||||
log.Info("can't drag while dropdown or textbox are active", w, h)
|
||||
return
|
||||
}
|
||||
*/
|
||||
if me.mouse.mouseUp {
|
||||
return
|
||||
}
|
||||
|
||||
if me.mouse.globalMouseDown {
|
||||
// log.Info("msgMouseDown == true")
|
||||
// plugin will segfault if you don't keep this inside a check for msgMouseDown
|
||||
// don't move this code out of here
|
||||
var found bool = false
|
||||
if me.mouse.currentDrag != nil {
|
||||
// me.mouse.currentDrag.dumpWidget(fmt.Sprintf("MM (%3d,%3d)", w, h))
|
||||
me.mouse.currentDrag.moveNew()
|
||||
return
|
||||
}
|
||||
// new function that is smarter
|
||||
if tk := findWindowUnderMouse(); tk != nil {
|
||||
// if me.mouse.globalMouseDown {
|
||||
// log.Info("msgMouseDown == true")
|
||||
// plugin will segfault if you don't keep this inside a check for msgMouseDown
|
||||
// don't move this code out of here
|
||||
var found bool = false
|
||||
if me.mouse.currentDrag != nil {
|
||||
// me.mouse.currentDrag.dumpWidget(fmt.Sprintf("MM (%3d,%3d)", w, h))
|
||||
me.mouse.currentDrag.moveNew()
|
||||
return
|
||||
}
|
||||
// new function that is smarter
|
||||
if tk := findWindowUnderMouse(); tk != nil {
|
||||
me.mouse.currentDrag = tk
|
||||
return
|
||||
}
|
||||
// first look for windows
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Window {
|
||||
me.mouse.currentDrag = tk
|
||||
return
|
||||
}
|
||||
// first look for windows
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Window {
|
||||
me.mouse.currentDrag = tk
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now look for the STDOUT window
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Flag {
|
||||
// now look for the STDOUT window
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Flag {
|
||||
me.mouse.currentDrag = tk
|
||||
// tk.moveNew()
|
||||
return
|
||||
}
|
||||
}
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Stdout {
|
||||
me.mouse.currentDrag = tk
|
||||
// tk.moveNew()
|
||||
return
|
||||
}
|
||||
/*
|
||||
if tk.node.WidgetType == widget.Label {
|
||||
me.mouse.currentDrag = tk
|
||||
// tk.moveNew()
|
||||
return
|
||||
}
|
||||
}
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Stdout {
|
||||
me.mouse.currentDrag = tk
|
||||
// tk.moveNew()
|
||||
return
|
||||
}
|
||||
/*
|
||||
if tk.node.WidgetType == widget.Label {
|
||||
me.mouse.currentDrag = tk
|
||||
// tk.moveNew()
|
||||
return
|
||||
}
|
||||
*/
|
||||
found = true
|
||||
}
|
||||
if !found {
|
||||
log.Info(fmt.Sprintf("findByXY() empty. nothing to move at (%d,%d)", w, h))
|
||||
}
|
||||
*/
|
||||
found = true
|
||||
}
|
||||
if !found {
|
||||
log.Info(fmt.Sprintf("findByXY() empty. nothing to move at (%d,%d)", w, h))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
21
structs.go
21
structs.go
|
@ -75,17 +75,16 @@ type config struct {
|
|||
|
||||
// stuff controlling how the mouse works
|
||||
type mouse struct {
|
||||
down time.Time // when the mouse was pressed down
|
||||
up time.Time // when the mouse was released. used to detect click vs drag
|
||||
clicktime time.Duration // how long is too long for a mouse click vs drag
|
||||
mouseUp bool // is the mouse up?
|
||||
double bool // user is double clicking
|
||||
doubletime time.Duration // how long is too long for double click
|
||||
resize bool // mouse is resizing something
|
||||
downW int // where the mouse was pressed down
|
||||
downH int // where the mouse was pressed down
|
||||
currentDrag *guiWidget // what widget is currently being moved around
|
||||
globalMouseDown bool // yep, mouse is pressed
|
||||
down time.Time // when the mouse was pressed down
|
||||
up time.Time // when the mouse was released. used to detect click vs drag
|
||||
clicktime time.Duration // how long is too long for a mouse click vs drag
|
||||
mouseUp bool // is the mouse up?
|
||||
double bool // user is double clicking
|
||||
doubletime time.Duration // how long is too long for double click
|
||||
resize bool // mouse is resizing something
|
||||
downW int // where the mouse was pressed down
|
||||
downH int // where the mouse was pressed down
|
||||
currentDrag *guiWidget // what widget is currently being moved around
|
||||
}
|
||||
|
||||
// settings for the stdout window
|
||||
|
|
Loading…
Reference in New Issue