microsoft / microsoft/microsoft-ui-xaml

Setting ProtectedCursor not working in RichEditBox

Open
#10,594 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Pointer team-Controls
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

Describe the bug

The goal is to show a "hand" cursor when the user hovers over a link in my RichEditBox.
In UWP I was able to do this by subclassing RichEditBox and overriding OnPointerMoved

protected override void OnPointerMoved(PointerRoutedEventArgs e)
{
    base.OnPointerMoved(e);
    if (GetLinkAtPosition(e.GetCurrentPoint(this).Position) == null) { return; }
    Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 1);
}
Steps to reproduce the bug

According to this answer, on WinUI3 I need to use ProtectedCursor. However, this code does not work, the "IBeam" cursor persists:

protected override void OnPointerMoved(PointerRoutedEventArgs e)
{
    base.OnPointerMoved(e);
    if (GetLinkAtPosition(e.GetCurrentPoint(this).Position) == null) { return; }
    ProtectedCursor = InputSystemCursor.Create(InputSystemCursorShape.Hand);
}
Expected behavior

No response

Screenshots

No response

NuGet package version

Windows App SDK 1.8 Experimental 2: 1.8.250515001-experimental2

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2 (22621, October 2024 Update)

IDE

Visual Studio 2022

Additional context

No response

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 with the RichEditBox subclass and its OnPointerMoved handler shown in the issue, using Windows App SDK 1.8 Experimental 2 on the stated Windows 11 version to reproduce the persistent IBeam cursor. Investigate the ProtectedCursor behavior for link hover and verify that the cursor changes to Hand over links without changing unrelated RichEditBox pointer behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.