mouse clicks work on libnotify menu

This commit is contained in:
Jeff Carr 2025-03-03 18:36:50 -06:00
parent efb5ede4b9
commit 046e6b4d6c
3 changed files with 42 additions and 9 deletions

View File

@ -207,6 +207,19 @@ func (tk *guiWidget) setColorButtonDense() {
tk.updateColor() 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() { func (tk *guiWidget) setColorButton() {
if tk.color == nil { if tk.color == nil {
tk.color = new(colorT) tk.color = new(colorT)

View File

@ -42,7 +42,20 @@ func doMouseClick(w int, h int) {
win := findWindowUnderMouse() win := findWindowUnderMouse()
if win == nil { 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 return
} }
if !win.isWindowActive() { if !win.isWindowActive() {

View File

@ -78,9 +78,9 @@ func makeNotifyMenu(wId int) {
me.notify.menu.tk.dumpWidget("init() menu") me.notify.menu.tk.dumpWidget("init() menu")
w, _ := me.baseGui.Size() w, _ := me.baseGui.Size()
me.notify.menu.tk.MoveToOffset(w-5, me.notify.menu.offsetH) 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.frame = false
me.notify.menu.tk.setColorButton() me.notify.menu.tk.setColorNotifyMenu()
me.notify.menu.tk.Show() me.notify.menu.tk.Show()
me.notify.menu.active = true me.notify.menu.active = true
me.notify.menu.tk.dumpWidget("notifyMenu()") me.notify.menu.tk.dumpWidget("notifyMenu()")
@ -119,7 +119,7 @@ func libNotifyUpdate() {
me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN) me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN)
hardDrawAtgocuiSize(me.notify.clock.tk) hardDrawAtgocuiSize(me.notify.clock.tk)
// hardDrawUnderMouse(me.notify.clock.tk, "clock") // 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 { if me.notify.menu.tk == nil {
log.Info("libNotifyUpdate error menu.tk == nil") log.Info("libNotifyUpdate error menu.tk == nil")
@ -131,15 +131,22 @@ func libNotifyUpdate() {
} }
// update the menu // 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) hardDrawAtgocuiSize(me.notify.menu.tk)
me.notify.menu.tk.setColorNotifyMenu()
me.baseGui.SetViewOnTop(me.notify.menu.tk.v.Name()) me.baseGui.SetViewOnTop(me.notify.menu.tk.v.Name())
me.baseGui.SetViewOnTop(me.notify.clock.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 // 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 // depending on the state the user has chosen
func setThingsOnTop() { func setThingsOnTop() {
@ -227,7 +234,7 @@ func hardDrawAtgocuiSize(tk *guiWidget) {
tk.v.Frame = false tk.v.Frame = false
tk.v.Clear() tk.v.Clear()
tk.v.WriteString(tk.labelN) 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 // find the "BG" widget and set it to the background on the very very bottom