more code cleanups
This commit is contained in:
parent
c5cada3dc9
commit
90a9f84f10
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/awesome-gocui/gocui"
|
||||
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||
|
@ -22,7 +21,6 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
|||
*/
|
||||
|
||||
me.mouse.mouseUp = true
|
||||
// me.mouse.globalMouseDown = false
|
||||
me.mouse.currentDrag = nil
|
||||
|
||||
if me.mouse.double && (time.Since(me.mouse.down) < me.mouse.doubletime) {
|
||||
|
@ -46,7 +44,6 @@ 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.mouseUp = false
|
||||
me.mouse.down = time.Now()
|
||||
w, h := g.MousePosition()
|
||||
|
@ -72,85 +69,6 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
win.setAsDragging()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if time.Since(me.mouse.down) < me.mouse.clicktime {
|
||||
log.Info("not yet")
|
||||
return nil
|
||||
}
|
||||
|
||||
w, h := g.MousePosition()
|
||||
|
||||
// if the dropdown is active, never do anything else
|
||||
if me.dropdown.active {
|
||||
log.Info("mouseDown() stopping here. dropdwon menu is in effect")
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if (tk.node.WidgetType == widget.Flag) && (tk == me.dropdown.tk) {
|
||||
// log.Info("SENDING CLICK TO Flag (dropdown)")
|
||||
tk.doWidgetClick(w, h)
|
||||
me.dropdown.active = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
log.Info("never found dropdown at", w, h)
|
||||
return nil
|
||||
}
|
||||
|
||||
// if the textbox is active, never do anything else
|
||||
if me.textbox.active {
|
||||
log.Info("mouseDown() stopping here. textbox widget is open")
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if (tk.node.WidgetType == widget.Flag) && (tk == me.textbox.tk) {
|
||||
me.textbox.active = false
|
||||
textboxClosed()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
log.Info("never found textbox at", w, h)
|
||||
return nil
|
||||
}
|
||||
// figre out what window this is
|
||||
win := findWindowUnderMouse()
|
||||
if win == nil {
|
||||
log.Info("mouseDown() nothing to click on at", w, h)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
// me.mouse.currentDrag = tk
|
||||
|
||||
/*
|
||||
if !tk.isWindowActive() {
|
||||
tk.makeWindowActive()
|
||||
return nil
|
||||
}
|
||||
|
||||
// log.Info("SENDING mouseDown() to findWindowUnderMouse()")
|
||||
if tk.node.WidgetType == widget.Window {
|
||||
// check to see if this is a direct click on a widget
|
||||
for _, tk := range tk.findByXYreal(w, h) {
|
||||
// tk.dumpWidget("mouseDown()")
|
||||
if tk.node.WidgetType == widget.Button {
|
||||
// log.Info("SENDING CLICK TO Button")
|
||||
tk.doWidgetClick(w, h)
|
||||
return nil
|
||||
}
|
||||
if tk.node.WidgetType == widget.Checkbox {
|
||||
// log.Info("SENDING CLICK TO Checkbox")
|
||||
tk.doWidgetClick(w, h)
|
||||
return nil
|
||||
}
|
||||
if tk.node.WidgetType == widget.Dropdown {
|
||||
// log.Info("SENDING CLICK TO Dropdown")
|
||||
tk.doWidgetClick(w, h)
|
||||
return nil
|
||||
}
|
||||
if tk.node.WidgetType == widget.Textbox {
|
||||
// log.Info("SENDING CLICK TO Textbox")
|
||||
tk.doWidgetClick(w, h)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -77,7 +77,20 @@ func doMouseClick(w int, h int) {
|
|||
}
|
||||
|
||||
win := findWindowUnderMouse()
|
||||
if win != nil {
|
||||
if win == nil {
|
||||
log.Log(GOCUI, "click() nothing was at:", w, h)
|
||||
return
|
||||
}
|
||||
if !win.isWindowActive() {
|
||||
win.makeWindowActive()
|
||||
return
|
||||
} else {
|
||||
// potentally the user is closing the window
|
||||
if win.checkWindowClose(w, h) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// look in this window for widgets
|
||||
// widgets have priority. send the click here first
|
||||
for _, tk := range win.findByXYreal(w, h) {
|
||||
|
@ -111,13 +124,9 @@ func doMouseClick(w int, h int) {
|
|||
// tk.dumpWidget("undef click()") // enable this to debug widget clicks
|
||||
}
|
||||
}
|
||||
if win.checkWindowClose(w, h) {
|
||||
return
|
||||
}
|
||||
// log.Info("you clicked on a window, but not any widgets. check for title / close window here", win.cuiName)
|
||||
win.makeWindowActive()
|
||||
return
|
||||
}
|
||||
// win.makeWindowActive()
|
||||
// return
|
||||
|
||||
var found bool
|
||||
|
||||
|
|
|
@ -74,12 +74,6 @@ 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)
|
||||
return
|
||||
}
|
||||
*/
|
||||
if me.mouse.mouseUp {
|
||||
return
|
||||
}
|
||||
|
@ -92,41 +86,6 @@ func mouseMove(g *gocui.Gui) {
|
|||
}
|
||||
log.Info(fmt.Sprintf("gui toolkit error. nothing to drag at (%d,%d)", w, h))
|
||||
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
|
||||
/*
|
||||
// new function that is smarter
|
||||
if tk := findWindowUnderMouse(); tk != nil {
|
||||
tk.setAsDragging()
|
||||
return
|
||||
}
|
||||
// first look for windows
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Window {
|
||||
tk.setAsDragging()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// now look for the STDOUT window
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Flag {
|
||||
tk.setAsDragging()
|
||||
return
|
||||
}
|
||||
}
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.node.WidgetType == widget.Stdout {
|
||||
tk.setAsDragging()
|
||||
// tk.moveNew()
|
||||
return
|
||||
}
|
||||
found = true
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func (tk *guiWidget) setAsDragging() {
|
||||
|
|
Loading…
Reference in New Issue