stride3d / stride3d/stride

Ui does not properly handle mouse-out from the ui itself.

Open
#1,130 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-UI bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

When the mouse leaves the ui, the mouse-out event is not processed.
This can be seen here:
https://github.com/stride3d/stride/blob/master/sources/engine/Stride.UI/Rendering/UI/UIRenderFeature.Picking.cs#L249
Basically if the mouse is not within the bounds, the mouse is not handled. While this is correct theoretically, it will also skip invoking the mouse out event for the currently hovered element, leaving it in the hovered state.

This can be seen here:
Animation

A hacked workaround is this:

        protected override bool BeginDraw()
        {
            this.uiRenderFeature ??= this.SceneSystem.GraphicsCompositor.RenderFeatures.OfType<UIRenderFeature>().FirstOrDefault();
            this.uiElementUnderMouseCursor = this.uiRenderFeature?.UIElementUnderMouseCursor;

            return base.BeginDraw();
        }

        protected override void EndDraw(bool present)
        {
            if (this.uiElementUnderMouseCursor != null && this.uiRenderFeature?.UIElementUnderMouseCursor == null)
                this.uiElementUnderMouseCursor?.GetType().GetProperty("MouseOverState")?.SetValue(this.uiElementUnderMouseCursor, MouseOverState.MouseOverNone);
            
            base.EndDraw(present);
        }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at sources/engine/Stride.UI/Rendering/UI/UIRenderFeature.Picking.cs#L249 and trace the bounds check and current hovered-element handling. Reproduce the mouse leaving the UI using the linked animation as a guide. Done means the previously hovered element receives its mouse-out event and no longer remains hovered when the pointer is outside the UI.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.