diff options
| author | Jeff Carr <[email protected]> | 2025-02-06 17:29:17 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-06 17:29:17 -0600 |
| commit | f5d465901d2ec48e145c3c7ce04eceb69445a11f (patch) | |
| tree | 0aa6f6f9edd9c7bb8fb3c4a3b304c3f9a63d6a42 /eventMouseClick.go | |
| parent | e134ecb6a4285d576c45c3f86274703f32ab30b0 (diff) | |
trying to send Close Window() from toolkit plugin
Diffstat (limited to 'eventMouseClick.go')
| -rw-r--r-- | eventMouseClick.go | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/eventMouseClick.go b/eventMouseClick.go index 222cb81..0d09007 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -4,12 +4,60 @@ package main import ( + "fmt" + "github.com/awesome-gocui/gocui" "go.wit.com/log" "go.wit.com/widget" ) -func (tk *guiWidget) doWindowClick(w int, h int) { +/* +func (tk *guiWidget) DeleteNode() { + p := tk.parent + for i, child := range p.children { + log.Log(GOCUI, "parent has child:", i, child.node.WidgetId, child.node.GetProgName()) + if tk == child { + log.Log(GOCUI, "Found child ==", i, child.node.WidgetId, child.node.GetProgName()) + log.Log(GOCUI, "Found n ==", i, tk.node.WidgetId, tk.node.GetProgName()) + p.children = append(p.children[:i], p.children[i+1:]...) + } + } + for i, child := range p.children { + log.Log(TREE, "parent now has child:", i, child.WidgetId, child.GetProgName()) + } +} +*/ + +func (tk *guiWidget) doWindowClick() { + w, h := me.baseGui.MousePosition() + // compare the mouse location to the 'X' indicator to close the window + if tk.gocuiSize.inRect(w, h) { + offset := w - tk.gocuiSize.w1 + if (offset < 2) && (offset > -2) { + // close enough // close the window here + tk.dumpWidget(fmt.Sprintf("Close Window(%d,%d) (off=%d)", w, h, offset)) + tk.hideWindow() + n := tk.node + tk.deleteNode() + me.myTree.SendWindowCloseEvent(n) + /* + n.DeleteNode() + + tk.DeleteNode() + */ + return + } + if tk.window.collapsed { + tk.dumpWidget(fmt.Sprintf("collapse = false")) + tk.window.collapsed = false + } else { + tk.dumpWidget(fmt.Sprintf("collapse = true")) + tk.window.collapsed = true + } + } else { + tk.window.collapsed = false + // tk.dumpWidget(fmt.Sprintf("No (%d,%d)", w, h)) + } // if there is a current window, hide it if me.currentWindow != nil { me.currentWindow.setColor(&colorWindow) @@ -28,7 +76,8 @@ func (tk *guiWidget) doWindowClick(w int, h int) { func (tk *guiWidget) doWidgetClick(w int, h int) { switch tk.node.WidgetType { case widget.Window: - tk.doWindowClick(w, h) + // tk.dumpWidget("doWidgetClick()") + tk.doWindowClick() return case widget.Group: case widget.Checkbox: |
