Skip to content

[#2856] Refactor pointer hover#2857

Open
oznogon wants to merge 6 commits intodaid:masterfrom
oznogon:fix-hover
Open

[#2856] Refactor pointer hover#2857
oznogon wants to merge 6 commits intodaid:masterfrom
oznogon:fix-hover

Conversation

@oznogon
Copy link
Copy Markdown
Contributor

@oznogon oznogon commented Apr 14, 2026

Reuse the reverse recursive child iteration of getClickElement() to manage hover state in getHoverElement(), instead of applying hover state to all elements in the stack that share the pointer's coordinates. This prevents hover state from bleeding into elements occluded by higher elements.

Hover checks and hover_coordinates assignment are now made during GuiContainer::drawElements(). Elements are tagged as intercepting the pointer for hover state with the GuiElement::intercepts_pointer Boolean, with non-interactive elements defaulting to false to pass hover state through.

Before: Hover state unexpectedly passes through to occluded elements

Screencast_20260414_084527.webm

After: Hover state is caught by the occluding elements

Screencast_20260414_084439.webm

Fixes #2856.

oznogon added 6 commits April 13, 2026 22:37
- Add GuiContainer::getHoverElement() to return the GUI element being
  hovered at the mouse position. This is patterend after
  getClickElement() but uses interceptsPointer() instead of
  onMouseDown().
- Add GuiContainer::clearHover() to clear active hover effects for an
  element and its children.
Implement new per-element hover detection on GuiCanvas, which recurses
into child elements.
Since we already iterate on elements in drawElements, check and
clear hover there if necessary instead of in a separate pass. This
changes the arguments for drawElements to pass the hovered element.
...GuiElement subclasses + frequencyCurve
@oznogon oznogon changed the title Refactor pointer hover [#2856] Refactor pointer hover Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Elements obscured by other higher elements still activate hover state

1 participant