The first click is good, but the second and the third click hide the cursor without showing the rectangle. You can see from the screenshot gif, the first three clicks don't show the rectangle, only the fourth click shows the rectangle. But I noticed that the hidden of cursor happens before the shown of native control. I can understand that when native control overlays WebView2, it no longer receive mouse event. Recently I find WebView2 provides more useful API than WebView, so I migrate to WebView2 and encounter problems like this one. When I used to use legacy EdgeHTML WebView, this scenario works fine. I can see same scenario from some other UWP apps, such as some news apps, they use WebView (haven't migrate to WebView2) to display news articles, and if users click images within article, they shows a native image carousel over WebView. Though I can use web technology to make an image carousel within WebView2, but native image control and carousel provides better performance and interactivity and I wouldn't like to change web content. My scenario is when user click image in WebView2, the app shows a FlipView over WebView2 to provide an image carousel. The problem may not be 100% reproduceable.At this time, cursor will not appear even if you move the mouse. When you click the WebView2 content for more that 3 times, the handler shows the rectangle to mimic an overlay that lets users do something.
Click the WebView2, you can find the cursor may disappear, but when you moves mouse, the cursor will appear again.The WebView2 is navigated to a simple string and has a Tapped handler. In the MainPage, there are a WebView2 and a rectangle on it, but the rectangle is initially hidden.
CURSOR MOVES BUT APPS WILL NOT OPEN CODE
I have tested similar code with WinUI3 and it seems not have the same problem. I created a minimum project that can reproduce the problem: But since I show an overlay as response to user click, and the overlay prevents cursor to appear, so when this happens, users can't see cursor on native control overlay anymore. But I find that that's very likely that clicks in WebView2 may cause mouse cursor to hide, that's fine if I only use WebView2 because users can move the mouse and the cursor will reappear. When users click within WebView2, I show some native controls as overlay to let users do something. I combine WebView2 and native controls in my UWP app.