diff --git a/tools/tui/loop/api.go b/tools/tui/loop/api.go index 2c083eb10..669ee3e0e 100644 --- a/tools/tui/loop/api.go +++ b/tools/tui/loop/api.go @@ -493,6 +493,8 @@ func (self *Loop) PopPointerShape() { } } +// Remove all pointer shapes from the shape stack resetting to default pointer +// shape. This is called automatically on loop termination. func (self *Loop) ClearPointerShapes() (ans []PointerShape) { ans = self.pointer_shapes for i := len(self.pointer_shapes) - 1; i >= 0; i-- { diff --git a/tools/tui/mouse.go b/tools/tui/mouse.go index eb1a56b6d..72f222402 100644 --- a/tools/tui/mouse.go +++ b/tools/tui/mouse.go @@ -289,11 +289,20 @@ func (m *MouseState) ApplyHoverStyles(lp *loop.Loop, style ...string) { } else { hs = style[0] } + is_hovered := false for id := range m.hovered_ids.Iterable() { for _, r := range m.region_id_map[id] { lp.StyleRegion(hs, r.TopLeft.X, r.TopLeft.Y, r.BottomRight.X, r.BottomRight.Y) + is_hovered = true } } + if is_hovered { + if s, has := lp.CurrentPointerShape(); !has || s != loop.POINTER_POINTER { + lp.PushPointerShape(loop.POINTER_POINTER) + } + } else { + lp.ClearPointerShapes() + } } func (m *MouseState) ClickHoveredRegions() error {