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