diff options
| author | Jeff Carr <[email protected]> | 2025-03-03 18:36:50 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-03 18:36:50 -0600 |
| commit | 046e6b4d6ce30302e155615d1e7b8004dd03e97d (patch) | |
| tree | 14943498bc6acccf4e0f662fc7566d52ffe299e0 | |
| parent | efb5ede4b94110da1c674542ec087a6a1dceaa99 (diff) | |
mouse clicks work on libnotify menu
| -rw-r--r-- | color.go | 13 | ||||
| -rw-r--r-- | eventMouseClick.go | 15 | ||||
| -rw-r--r-- | libnotify.go | 21 |
3 files changed, 41 insertions, 8 deletions
@@ -207,6 +207,19 @@ func (tk *guiWidget) setColorButtonDense() { tk.updateColor() } +func (tk *guiWidget) setColorNotifyMenu() { + if tk.color == nil { + tk.color = new(colorT) + } + tk.color.frame = gocui.AttrNone + tk.color.fg = gocui.ColorWhite + tk.color.bg = gocui.ColorBlue + tk.color.selFg = gocui.ColorBlue + tk.color.selBg = gocui.AttrNone + + tk.updateColor() +} + func (tk *guiWidget) setColorButton() { if tk.color == nil { tk.color = new(colorT) diff --git a/eventMouseClick.go b/eventMouseClick.go index 4ef2114..4229964 100644 --- a/eventMouseClick.go +++ b/eventMouseClick.go @@ -42,7 +42,20 @@ func doMouseClick(w int, h int) { win := findWindowUnderMouse() if win == nil { - log.Log(GOCUI, "click() nothing was at:", w, h) + log.Log(INFO, "click() nothing was at:", w, h) + log.Log(INFO, "click() check if", w, h, "is the libnotify menu") + if me.notify.menu.tk != nil && me.notify.menu.tk.gocuiSize.inRect(w, h) { + log.Log(GOCUI, "click() is libnotify menu!") + if me.showHelp { + log.Info("show help") + showHelp() + setNotifyMenuText("[X]") + } else { + log.Info("hide help") + hideHelp() + setNotifyMenuText("[ ]") + } + } return } if !win.isWindowActive() { diff --git a/libnotify.go b/libnotify.go index b06e962..9658ad2 100644 --- a/libnotify.go +++ b/libnotify.go @@ -78,9 +78,9 @@ func makeNotifyMenu(wId int) { me.notify.menu.tk.dumpWidget("init() menu") w, _ := me.baseGui.Size() me.notify.menu.tk.MoveToOffset(w-5, me.notify.menu.offsetH) - me.notify.menu.tk.labelN = "|jwc|" + me.notify.menu.tk.labelN = "[ ]" me.notify.menu.tk.frame = false - me.notify.menu.tk.setColorButton() + me.notify.menu.tk.setColorNotifyMenu() me.notify.menu.tk.Show() me.notify.menu.active = true me.notify.menu.tk.dumpWidget("notifyMenu()") @@ -119,7 +119,7 @@ func libNotifyUpdate() { me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN) hardDrawAtgocuiSize(me.notify.clock.tk) // hardDrawUnderMouse(me.notify.clock.tk, "clock") - log.Info("libNotifyUpdate updated clock", me.notify.clock.tk.labelN) + // log.Info("libNotifyUpdate updated clock", me.notify.clock.tk.labelN) if me.notify.menu.tk == nil { log.Info("libNotifyUpdate error menu.tk == nil") @@ -131,13 +131,20 @@ func libNotifyUpdate() { } // update the menu + hardDrawAtgocuiSize(me.notify.menu.tk) + me.notify.menu.tk.setColorNotifyMenu() + me.baseGui.SetViewOnTop(me.notify.menu.tk.v.Name()) + me.baseGui.SetViewOnTop(me.notify.clock.tk.v.Name()) +} + +func setNotifyMenuText(s string) { me.notify.menu.tk.v.Clear() - me.notify.menu.tk.labelN = "||jwc|" + me.notify.menu.tk.labelN = s me.notify.menu.tk.v.WriteString(me.notify.menu.tk.labelN) - // hardDrawUnderMouse(me.notify.menu.tk, "menu") hardDrawAtgocuiSize(me.notify.menu.tk) + me.notify.menu.tk.setColorNotifyMenu() me.baseGui.SetViewOnTop(me.notify.menu.tk.v.Name()) - me.baseGui.SetViewOnTop(me.notify.clock.tk.v.Name()) + log.Info("setNotifyMenuText() updated menu to:", me.notify.menu.tk.labelN) } // in the very end of redrawing things, this will place the help and stdout on the top or botton @@ -227,7 +234,7 @@ func hardDrawAtgocuiSize(tk *guiWidget) { tk.v.Frame = false tk.v.Clear() tk.v.WriteString(tk.labelN) - log.Info("hardDrawAtgocuiSize() err ok widget", tk.cuiName, a, b, c, d, tk.v.Name()) + log.Verbose("hardDrawAtgocuiSize() err ok widget", tk.cuiName, a, b, c, d, tk.v.Name()) } // find the "BG" widget and set it to the background on the very very bottom |
