dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
6.93k stars 1.15k forks source link

Tooltips not closing for custom render controls #7134

Open NVN-Logis opened 1 year ago

NVN-Logis commented 1 year ago

Issue is seen with .NET6.0, including latest 6.0.401 Issue was not present in .NET framework 4.8 Seen on both Windows 10 and 11.

The attached project demonstrates the issue: If a custom render control does not draw portions of the area that the control covers, then the tooltip should close when the mouse moves off of the drawn parts, as it did in .NET4.8. What is observed is that the tooltip stays open as long as the mouse is over the control, including the non-drawn area.

Demonstration: .NET 6.0 dotnet6 0

Demonstration: .NET 4.8 dotnet4 8

WpfApp3.zip

lindexi commented 1 year ago

Reference: https://github.com/dotnet/wpf/pull/6332

See https://github.com/dotnet/wpf/issues/4612

It looks like ToolTip is just judging the size of the control but doesn't perform hit testing.

The size of the TestControl is as big as the window.

It means that the ToolTip do not close because the ToolTip will think the mouse is always on the control and not disappear.

How about add the Margin to TestControl to test it:

        <local:TestControl Margin="10,10,10,100" ToolTip="AAAAAAAAAAA" x:Name="Test"/>

Cc @SamBent

NVN-Logis commented 1 year ago

@lindexi Yes, that is what I think, too. As demonstrated, this is not how it worked in 4.8,

skrysmanski commented 1 year ago

@NVN-Logis Could you check - on a machine with the latest Windows patches - if the behavior on .NET 4.8 is still like you'd expect it? I'm seeing a behavior similar to the .NET 6 behavior on my .NET 4.8 application since the last patch day.

NVN-Logis commented 1 year ago

@skrysmanski I just updated (Win11) and checked: No change. Still works as expected for .NET 4.8

skrysmanski commented 1 year ago

@NVN-Logis Thanks for the feedback. In the meantime I've figure out the cause for my problems (The .NET 4.8.1 runtime breaks WPF tooltips when a progress bar with IsIndeterminate="True" is used).

Mgamerz commented 1 year ago

This still seems to be an issue; I am having odd behavior with my tooltips not closing (.NET 6 on Windows 11), which is causing them to appear to be showing on wrong elements. The behavior is similar to what's shown in the OP. Would be nice to see this fixed.

Mgamerz commented 1 month ago

Still an issue on .NET 8, though not sure if it is because the underlying element moved and the hitboxes were not updated (no idea how I would do that).

2024-06-06_21h23_48