CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.89k stars 1.38k forks source link

Gridsplitter controls sometimes causes the pointer to disappear #2017

Open fatcatz888 opened 6 years ago

fatcatz888 commented 6 years ago

I'm submitting a...

Bug report (I searched for similar issues and did not find one)

Current behavior

If my app navigates to a new page with gridsplitter controls sometimes the cursor disappears. The cursor only appears if hovering over a gridsplitter control.

Expected behavior

The cursor should be visible.

Minimal reproduction of the problem with instructions

Create a page with 2 gridsplitter controls, then from the main page navigate back and forth a few times to the page with the gridsplitters. Eventually, the cursor disappears.

Environment

Nuget Package(s): 
Microsoft.Toolkit v2.2.0
Microsoft.Toolkit.Uwp v2.2.0
Microsoft.Toolkit.Uwp v2.2.0
Microsoft.Toolkit.Uwp.Controls v2.2.0

Package Version(s): 

Windows 10 Build Number:
- [ ] Anniversary Update (14393) 
- [ ] Creators Update (15063)
- [X ] Fall Creators Update (16299)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Anniversary Update (14393) 
- [ ] Creators Update (15063)
- [X ] Fall Creators Update (16299)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x ] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ X] 2017 (version: version: 15.6.6)
- [ ] 2017 Preview (version: )
nmetulev commented 6 years ago

@shweaver-MSFT, could you look at this as part of #2013?

shweaver-MSFT commented 6 years ago

Ya, no problem. I'll try out the repro and see what's going on.

shweaver-MSFT commented 6 years ago

@nmetulev, I can't seem to repro the issue. I created an app with 2 pages. MainPage has a button that navigates to the OtherPage. OtherPage has 2 GridSplitters and a few buttons to navigate back to Main. I tried navigating back/forth dozens of times with no issue. Cursor is always visible and changes as expected when hovering/manipulating the GridSplitter.

Test app is here: https://github.com/shweaver-MSFT/GridSplitterCursorTest

@fatcatz888, would you mind trying out the test app to compare with the issue you are seeing? Or do you have an encapsulated repro I could try?

fatcatz888 commented 6 years ago

I'll give it a test.

Thanks

michael-hawker commented 6 years ago

I just hit this too, but couldn't repro again when I redid what I thought I did. We can clean-up the GridSplitter to use our Mouse Cursor extensions, that may help maybe. I can look at it after Build as I should try and finish and add in my ContentSizer sister control.

fatcatz888 commented 6 years ago

Thanks for the update. Since you can reproduce the bug too now I won't be pulling my hair out trying to get the test app to make the cursor disappear!

I just know it is completely random.

lucaasrojas commented 6 years ago

What's the current status of this issue?

lucaasrojas commented 6 years ago

I tried to replicate the issue using the v2.2 and v3.0 without success. I also tried moving the back button outside of the grid, but I couldn't replicate the issue.

kbrons commented 6 years ago

@michael-hawker Did you have a chance to look at this?

michael-hawker commented 6 years ago

@kbrons @shweaver-MSFT I think I hit this again. I was on a Surface Book, so I wonder if it's HW dependent?

fatcatz888 commented 6 years ago

FYI it just occurred again after I upgraded to 4.0.0. I was testing GridSplitter in the Windows Community Toolkit Sample App using a Desktop PC. If I open the Mouse extension example the cursor appears normal again.

kbrons commented 6 years ago

@fatcatz888 what's the hardware you're testing on? I can't reproduce it on a ThinkPad X1.

fatcatz888 commented 6 years ago

It happens on my Asus notebook (n550) and Asus desktop. I'm quite sure it is not hardware as I have other UWP apps that do not have this issue.

My only app that uses the GridSplitter shows this issue. If the mouse moves out of the app's window the cursor reappears. Move it back inside the app's window, the cursor disappears.

I've added code so that if the user manages to hit the back button to go back to the main page then my app forces the cursor to show again with code at OnNavigatedTo

if (e.NavigationMode == NavigationMode.New)
  {
    _defaultCursor = Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor;
   }
   else
   {
     if (_defaultCursor != Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor)
     {
       Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = _defaultCursor;
     }
}

This seems to partly fix the issus.

michael-hawker commented 5 years ago

I know the GridSplitter uses a different implementation, but I need to compare it to the Mouse Cursor extension ones as I can hit this issue with the Mouse Cursor extensions as well.

michael-hawker commented 5 years ago

I have a fix for the Mouse Cursor extension, and I suspect the problem is the same here (though we should have Grid Splitter use the Mouse extensions).

Turns out Pointer Exit is sometimes called originating from the element itself, which in turn causes it to set the pointer to the changed cursor instead of back to something else.

I added a sender != e.OriginalSource to the if condition and that seems to work like a charm. I'll make sure to submit that fix soon for Mouse Cursor and see if it can be applied here.

michael-hawker commented 5 years ago

Grid Splitter's logic is different and much more complex than the Mouse extension. I think for 6.0 we refactor Grid Splitter to use the Mouse Extension. I already have an implementation we can use of a 'ContentSplitter' that uses the extensions. I'll submit a PR soon after the 5.1 release.

michael-hawker commented 5 years ago

@azchohfi this is still an issue, I had just referenced it in the other PR as I thought it was the same originally and its where the fix stemmed from. I'm going to resolve this issue in 6.0 by making GridSplitter use the fixed Mouse Cursor extensions.