hmm. can't figure out where clicks are going
This commit is contained in:
parent
f76960c907
commit
b7cd6d07fc
4
color.go
4
color.go
|
@ -148,10 +148,10 @@ func (tk *guiWidget) setColor(newColor *colorT) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if tk.color == nil {
|
if tk.color == nil {
|
||||||
log.Log(NOW, "Set the node to color = nil")
|
// log.Log(NOW, "Set the node to color = nil")
|
||||||
tk.color = &colorNone
|
tk.color = &colorNone
|
||||||
}
|
}
|
||||||
log.Log(NOW, "Set the node to color =", tk.color.name)
|
// log.Log(NOW, "Set the node to color =", tk.color.name)
|
||||||
tk.Show()
|
tk.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
|
log "go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// tells 'gocui' what to call based on what key was pressed
|
// tells 'gocui' what to call based on what key was pressed
|
||||||
|
@ -44,6 +47,14 @@ func openDebuggger(g *gocui.Gui, v *gocui.View) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func theFind(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
w, h := g.MousePosition()
|
||||||
|
for _, tk := range findByXY(w, h) {
|
||||||
|
log.Log(GOCUI, fmt.Sprintf("findByXY() 'f' key %-8s wId=%4d at (%3d,%3d) %s", tk.WidgetType, tk.node.WidgetId, w, h, tk.node.String()))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// is run whenever anyone hits 'd' (in an open space)
|
// is run whenever anyone hits 'd' (in an open space)
|
||||||
func theLetterD(g *gocui.Gui, v *gocui.View) error {
|
func theLetterD(g *gocui.Gui, v *gocui.View) error {
|
||||||
// widgets that don't have physical existance in
|
// widgets that don't have physical existance in
|
||||||
|
|
|
@ -65,11 +65,9 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||||
w, h := g.MousePosition()
|
w, h := g.MousePosition()
|
||||||
|
|
||||||
// useful to debug everything that is being clicked on
|
// useful to debug everything that is being clicked on
|
||||||
/*
|
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
log.Log(GOCUI, fmt.Sprintf("findByXY() mouseUp() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h))
|
log.Log(GOCUI, fmt.Sprintf("findByXY() mouseUp() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h))
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
dropdownUnclicked(w, h)
|
dropdownUnclicked(w, h)
|
||||||
|
|
||||||
|
@ -96,9 +94,13 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||||
func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
||||||
mx, my := g.MousePosition()
|
mx, my := g.MousePosition()
|
||||||
|
|
||||||
for _, w := range findByXY(mx, my) {
|
var found bool = false
|
||||||
log.Log(GOCUI, fmt.Sprintf("findByXY() mouseDown() %s wId=%d cuiName=%s at (%d,%d)", w.WidgetType, w.node.WidgetId, w.cuiName, mx, my))
|
for _, tk := range findByXY(mx, my) {
|
||||||
// w.doWidgetClick()
|
log.Log(GOCUI, fmt.Sprintf("findByXY() mouseDown() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, mx, my))
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
log.Log(GOCUI, fmt.Sprintf("findByXY() mouseDown() found nothing at (%d,%d)", mx, my))
|
||||||
}
|
}
|
||||||
|
|
||||||
vx0, vy0, vx1, vy1, err := g.ViewPosition("msg")
|
vx0, vy0, vx1, vy1, err := g.ViewPosition("msg")
|
||||||
|
|
|
@ -8,29 +8,12 @@ import (
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (w *guiWidget) doWidgetClick() {
|
// this whole things was impossible to make but it got me where I am now
|
||||||
switch w.WidgetType {
|
// the debugging is way way better now with it being visible in the Stdout window
|
||||||
/*
|
// so now it's possible to redo all this and make it better
|
||||||
case widget.Root:
|
func (tk *guiWidget) doWidgetClick(w int, h int) {
|
||||||
// THIS IS THE BEGINING OF THE LAYOUT
|
switch tk.WidgetType {
|
||||||
log.Log(GOCUI, "doWidgetClick()", w.String())
|
|
||||||
wRoot := me.treeRoot.TK.(*guiWidget)
|
|
||||||
wRoot.redoWindows(0, 0)
|
|
||||||
case widget.Flag:
|
|
||||||
log.Log(GOCUI, "doWidgetClick() FLAG widget name =", w.String())
|
|
||||||
log.Log(GOCUI, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
|
||||||
*/
|
|
||||||
case widget.Window:
|
case widget.Window:
|
||||||
log.Log(GOCUI, "doWidgetClick() START on window", w.String())
|
|
||||||
// if the user clicked on the current window, do nothing
|
|
||||||
/* Ignore this for now and redraw the window anyway
|
|
||||||
if me.currentWindow == w {
|
|
||||||
if !w.active {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// if there is a current window, hide it
|
// if there is a current window, hide it
|
||||||
if me.currentWindow != nil {
|
if me.currentWindow != nil {
|
||||||
me.currentWindow.setColor(&colorWindow)
|
me.currentWindow.setColor(&colorWindow)
|
||||||
|
@ -39,72 +22,67 @@ func (w *guiWidget) doWidgetClick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// now set this window as the current window
|
// now set this window as the current window
|
||||||
me.currentWindow = w
|
me.currentWindow = tk
|
||||||
me.currentWindow.isCurrent = true
|
me.currentWindow.isCurrent = true
|
||||||
|
|
||||||
// draw the current window
|
// draw the current window
|
||||||
log.Log(GOCUI, "doWidgetClick() set currentWindow to", w.String())
|
tk.setColor(&colorActiveW)
|
||||||
w.setColor(&colorActiveW)
|
tk.DrawAt(3, 2)
|
||||||
w.DrawAt(3, 2)
|
tk.placeWidgets(3, 2) // compute the sizes & places for each widget
|
||||||
w.placeWidgets(3, 2) // compute the sizes & places for each widget
|
tk.active = false
|
||||||
w.active = false
|
tk.showWidgets()
|
||||||
w.showWidgets()
|
|
||||||
/*
|
|
||||||
hideFake()
|
|
||||||
showDebug = true
|
|
||||||
*/
|
|
||||||
case widget.Group:
|
case widget.Group:
|
||||||
if w.active {
|
if tk.active {
|
||||||
w.active = false
|
tk.active = false
|
||||||
w.placeWidgets(w.startW, w.startH)
|
tk.placeWidgets(tk.startW, tk.startH)
|
||||||
w.showWidgets()
|
tk.showWidgets()
|
||||||
} else {
|
} else {
|
||||||
w.active = true
|
tk.active = true
|
||||||
for _, child := range w.children {
|
for _, child := range tk.children {
|
||||||
child.hideWidgets()
|
child.hideWidgets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case widget.Checkbox:
|
case widget.Checkbox:
|
||||||
if w.node.State.Checked {
|
if tk.node.State.Checked {
|
||||||
log.Log(WARN, "checkbox is being set to false")
|
log.Log(WARN, "checkbox is being set to false")
|
||||||
w.node.State.Checked = false
|
tk.node.State.Checked = false
|
||||||
w.setCheckbox()
|
tk.setCheckbox()
|
||||||
} else {
|
} else {
|
||||||
log.Log(WARN, "checkbox is being set to true")
|
log.Log(WARN, "checkbox is being set to true")
|
||||||
w.node.State.Checked = true
|
tk.node.State.Checked = true
|
||||||
w.setCheckbox()
|
tk.setCheckbox()
|
||||||
}
|
}
|
||||||
me.myTree.SendUserEvent(w.node)
|
me.myTree.SendUserEvent(tk.node)
|
||||||
case widget.Grid:
|
case widget.Grid:
|
||||||
newR := w.realGocuiSize()
|
newR := tk.realGocuiSize()
|
||||||
|
|
||||||
// w,h := n.logicalSize()
|
// w,h := n.logicalSize()
|
||||||
// w := newR.w1 - newR.w0
|
// w := newR.w1 - newR.w0
|
||||||
// h := newR.h1 - newR.h0
|
// h := newR.h1 - newR.h0
|
||||||
|
|
||||||
w.placeGrid(newR.w0, newR.h0)
|
tk.placeGrid(newR.w0, newR.h0)
|
||||||
w.showWidgets()
|
tk.showWidgets()
|
||||||
case widget.Box:
|
case widget.Box:
|
||||||
// w.showWidgetPlacement(logNow, "drawTree()")
|
if tk.node.State.Direction == widget.Horizontal {
|
||||||
if w.node.State.Direction == widget.Horizontal {
|
log.Log(GOCUI, "BOX IS HORIZONTAL", tk.String())
|
||||||
log.Log(GOCUI, "BOX IS HORIZONTAL", w.String())
|
|
||||||
} else {
|
} else {
|
||||||
log.Log(GOCUI, "BOX IS VERTICAL", w.String())
|
log.Log(GOCUI, "BOX IS VERTICAL", tk.String())
|
||||||
}
|
}
|
||||||
w.placeWidgets(w.startW, w.startH)
|
tk.placeWidgets(tk.startW, tk.startH)
|
||||||
w.toggleTree()
|
tk.toggleTree()
|
||||||
case widget.Button:
|
case widget.Button:
|
||||||
// doUserEvent(n)
|
// doUserEvent(n)
|
||||||
me.myTree.SendFromUser(w.node)
|
me.myTree.SendFromUser(tk.node)
|
||||||
case widget.Combobox:
|
case widget.Combobox:
|
||||||
log.Log(GOCUI, "do the combobox here")
|
log.Log(GOCUI, "do the combobox here")
|
||||||
w.showDropdown()
|
tk.showDropdown()
|
||||||
me.dropdownW = w
|
me.dropdownW = tk
|
||||||
case widget.Dropdown:
|
case widget.Dropdown:
|
||||||
log.Log(GOCUI, "do the dropdown here")
|
log.Log(GOCUI, "do the dropdown here")
|
||||||
w.showDropdown()
|
tk.showDropdown()
|
||||||
me.dropdownW = w
|
me.dropdownW = tk
|
||||||
default:
|
default:
|
||||||
|
log.Log(GOCUI, fmt.Sprintf("findByXY() blank click() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,12 +94,13 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
||||||
h := mouseH
|
h := mouseH
|
||||||
|
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
log.Log(GOCUI, fmt.Sprintf("findByXY() click() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h))
|
// will show you everything found on a mouse click. great for debugging!
|
||||||
|
// log.Log(GOCUI, fmt.Sprintf("findByXY() click() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h))
|
||||||
if tk.WidgetType == widget.Stdout {
|
if tk.WidgetType == widget.Stdout {
|
||||||
// don't send clicks to the stdout debugging window
|
// don't send clicks to the stdout debugging window
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tk.doWidgetClick()
|
tk.doWidgetClick(w, h)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue