mouse code is better than it's ever been
This commit is contained in:
parent
cf073e9aae
commit
00d1256eba
|
@ -46,6 +46,16 @@ func mouseMove(g *gocui.Gui) {
|
|||
v.Highlight = true
|
||||
}
|
||||
}
|
||||
|
||||
// old hack. create the 'msg' view if it does not yet exist
|
||||
// TODO: put this somewhere more correct
|
||||
if widgetView, _ := g.View("msg"); widgetView == nil {
|
||||
if createStdout(g) {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// END HIGHLIGHTING
|
||||
|
||||
// Super Mouse Mode. very useful for debugging in the past. also, just fun
|
||||
|
@ -57,30 +67,19 @@ func mouseMove(g *gocui.Gui) {
|
|||
}
|
||||
}
|
||||
|
||||
// how long has the mouse button been pressed down?
|
||||
if time.Since(me.mouse.down) < me.mouse.clicktime {
|
||||
// log.Info("not yet")
|
||||
if me.mouse.mouseUp {
|
||||
return
|
||||
}
|
||||
// EVERYTHING BELOW THIS IS RELATED TO MOUSE DRAGGING
|
||||
|
||||
// has the mouse been pressed down long enough to start dragging?
|
||||
if time.Since(me.mouse.down) < me.mouse.clicktime {
|
||||
// not dragging
|
||||
return
|
||||
}
|
||||
// okay, the mouse button has been pressed down for a while.
|
||||
// below here is mouse dragging
|
||||
|
||||
if me.dropdown.active || me.textbox.active {
|
||||
// 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
|
||||
|
||||
// create the 'msg' view if it does not yet exist // TODO: put this somewhere more correct
|
||||
if widgetView, _ := g.View("msg"); widgetView == nil {
|
||||
if createStdout(g) {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if me.mouse.mouseUp {
|
||||
// can't drag
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -90,7 +89,7 @@ func mouseMove(g *gocui.Gui) {
|
|||
me.mouse.currentDrag.moveNew()
|
||||
return
|
||||
}
|
||||
log.Info(fmt.Sprintf("gui toolkit error. nothing to drag at (%d,%d)", w, h))
|
||||
log.Info(fmt.Sprintf("gocui gui toolkit plugin error. nothing to drag at (%d,%d)", w, h))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue