microsoft / microsoft/microsoft-ui-xaml
Setting ProtectedCursor not working in RichEditBox
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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