From 046e6b4d6ce30302e155615d1e7b8004dd03e97d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 3 Mar 2025 18:36:50 -0600 Subject: [PATCH] mouse clicks work on libnotify menu --- color.go | 13 +++++++++++++ eventMouseClick.go | 15 ++++++++++++++- libnotify.go | 23 +++++++++++++++-------- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/color.go b/color.go index a815c81..761cb16 100644 --- a/color.go +++ b/color.go @@ -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,15 +131,22 @@ func libNotifyUpdate() { } // update the menu - me.notify.menu.tk.v.Clear() - me.notify.menu.tk.labelN = "||jwc|" - 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()) } +func setNotifyMenuText(s string) { + me.notify.menu.tk.v.Clear() + me.notify.menu.tk.labelN = s + me.notify.menu.tk.v.WriteString(me.notify.menu.tk.labelN) + hardDrawAtgocuiSize(me.notify.menu.tk) + me.notify.menu.tk.setColorNotifyMenu() + me.baseGui.SetViewOnTop(me.notify.menu.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 // depending on the state the user has chosen func setThingsOnTop() { @@ -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