From 8432cc70da8e3158d0fe31c55b6cce336624fb2c Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 24 Aug 2024 14:37:44 -0400 Subject: [PATCH] MenuItem focuses on hover Styles should remove MenuItem[hover] styling --- menuitem.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/menuitem.go b/menuitem.go index 6ab84bf..2c2e262 100644 --- a/menuitem.go +++ b/menuitem.go @@ -38,6 +38,8 @@ func NewIconMenuItem (icon tomo.Icon, text string) *MenuItem { box.Add(box.label) box.SetInputMask(true) + box.OnMouseEnter(box.handleMouseEnter) + box.OnMouseLeave(box.handleMouseLeave) box.OnButtonDown(box.handleButtonDown) box.OnButtonUp(box.handleButtonUp) box.OnKeyDown(box.handleKeyDown) @@ -62,6 +64,14 @@ func (this *MenuItem) OnClick (callback func ()) event.Cookie { return this.on.click.Connect(callback) } +func (this *MenuItem) handleMouseEnter () { + this.SetFocused(true) +} + +func (this *MenuItem) handleMouseLeave () { + this.SetFocused(false) +} + func (this *MenuItem) handleKeyDown (key input.Key, numberPad bool) bool { if key != input.KeyEnter && key != input.Key(' ') { return false } return true