microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Setting ProtectedCursor not working in RichEditBox

Open tipa opened this issue 7 months ago • 2 comments

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

tipa avatar May 26 '25 10:05 tipa

Hi @tipa , can you help us by providing minimal repro project for further investigation?

snigdha011997 avatar Jun 17 '25 06:06 snigdha011997

@snigdha011997 sure, see here: test.zip Hope it helps

tipa avatar Jun 17 '25 06:06 tipa

@snigdha011997 I provided a repro, why has the "needs-repro" tag been added?

tipa avatar Jun 26 '25 07:06 tipa