summaryrefslogtreecommitdiff
path: root/eventMouseClick.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-31 13:00:26 -0600
committerJeff Carr <[email protected]>2025-01-31 13:47:45 -0600
commitb7cd6d07fcaa69d009b3f33f7c59afb16b719029 (patch)
tree5acb4a3b04dd7603a6085a5be51b448227512a11 /eventMouseClick.go
parentf76960c90764159d1cad6b5264687accc39ca4bd (diff)
hmm. can't figure out where clicks are goingv0.22.15
Diffstat (limited to 'eventMouseClick.go')
-rw-r--r--eventMouseClick.go101
1 files changed, 40 insertions, 61 deletions
diff --git a/eventMouseClick.go b/eventMouseClick.go
index 01ad344..07235e4 100644
--- a/eventMouseClick.go
+++ b/eventMouseClick.go
@@ -8,29 +8,12 @@ import (
"go.wit.com/widget"
)
-func (w *guiWidget) doWidgetClick() {
- switch w.WidgetType {
- /*
- case widget.Root:
- // THIS IS THE BEGINING OF THE LAYOUT
- 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?")
- */
+// this whole things was impossible to make but it got me where I am now
+// 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
+func (tk *guiWidget) doWidgetClick(w int, h int) {
+ switch tk.WidgetType {
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 me.currentWindow != nil {
me.currentWindow.setColor(&colorWindow)
@@ -39,72 +22,67 @@ func (w *guiWidget) doWidgetClick() {
}
// now set this window as the current window
- me.currentWindow = w
+ me.currentWindow = tk
me.currentWindow.isCurrent = true
// draw the current window
- log.Log(GOCUI, "doWidgetClick() set currentWindow to", w.String())
- w.setColor(&colorActiveW)
- w.DrawAt(3, 2)
- w.placeWidgets(3, 2) // compute the sizes & places for each widget
- w.active = false
- w.showWidgets()
- /*
- hideFake()
- showDebug = true
- */
+ tk.setColor(&colorActiveW)
+ tk.DrawAt(3, 2)
+ tk.placeWidgets(3, 2) // compute the sizes & places for each widget
+ tk.active = false
+ tk.showWidgets()
case widget.Group:
- if w.active {
- w.active = false
- w.placeWidgets(w.startW, w.startH)
- w.showWidgets()
+ if tk.active {
+ tk.active = false
+ tk.placeWidgets(tk.startW, tk.startH)
+ tk.showWidgets()
} else {
- w.active = true
- for _, child := range w.children {
+ tk.active = true
+ for _, child := range tk.children {
child.hideWidgets()
}
}
case widget.Checkbox:
- if w.node.State.Checked {
+ if tk.node.State.Checked {
log.Log(WARN, "checkbox is being set to false")
- w.node.State.Checked = false
- w.setCheckbox()
+ tk.node.State.Checked = false
+ tk.setCheckbox()
} else {
log.Log(WARN, "checkbox is being set to true")
- w.node.State.Checked = true
- w.setCheckbox()
+ tk.node.State.Checked = true
+ tk.setCheckbox()
}
- me.myTree.SendUserEvent(w.node)
+ me.myTree.SendUserEvent(tk.node)
case widget.Grid:
- newR := w.realGocuiSize()
+ newR := tk.realGocuiSize()
// w,h := n.logicalSize()
// w := newR.w1 - newR.w0
// h := newR.h1 - newR.h0
- w.placeGrid(newR.w0, newR.h0)
- w.showWidgets()
+ tk.placeGrid(newR.w0, newR.h0)
+ tk.showWidgets()
case widget.Box:
- // w.showWidgetPlacement(logNow, "drawTree()")
- if w.node.State.Direction == widget.Horizontal {
- log.Log(GOCUI, "BOX IS HORIZONTAL", w.String())
+ if tk.node.State.Direction == widget.Horizontal {
+ log.Log(GOCUI, "BOX IS HORIZONTAL", tk.String())
} else {
- log.Log(GOCUI, "BOX IS VERTICAL", w.String())
+ log.Log(GOCUI, "BOX IS VERTICAL", tk.String())
}
- w.placeWidgets(w.startW, w.startH)
- w.toggleTree()
+ tk.placeWidgets(tk.startW, tk.startH)
+ tk.toggleTree()
case widget.Button:
// doUserEvent(n)
- me.myTree.SendFromUser(w.node)
+ me.myTree.SendFromUser(tk.node)
case widget.Combobox:
log.Log(GOCUI, "do the combobox here")
- w.showDropdown()
- me.dropdownW = w
+ tk.showDropdown()
+ me.dropdownW = tk
case widget.Dropdown:
log.Log(GOCUI, "do the dropdown here")
- w.showDropdown()
- me.dropdownW = w
+ tk.showDropdown()
+ me.dropdownW = tk
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
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 {
// don't send clicks to the stdout debugging window
continue
}
- tk.doWidgetClick()
+ tk.doWidgetClick(w, h)
return nil
}