Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix devtools selection highlight requiring direct hover over the control #5949

Merged
merged 2 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<TreeView.Styles>
<Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
<Setter Property="Background" Value="Transparent" />
</Style>
</TreeView.Styles>
</TreeView>
Expand Down
19 changes: 14 additions & 5 deletions src/Avalonia.Diagnostics/Diagnostics/Views/TreePageView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Controls.Generators;
Expand All @@ -6,6 +7,7 @@
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.VisualTree;

namespace Avalonia.Diagnostics.Views
{
Expand Down Expand Up @@ -100,12 +102,19 @@ private void TreeViewItemMaterialized(object sender, ItemContainerEventArgs e)
private void TreeViewItemTemplateApplied(object sender, TemplateAppliedEventArgs e)
{
var item = (TreeViewItem)sender;
var headerPresenter = item.HeaderPresenter;
headerPresenter.ApplyTemplate();

var header = headerPresenter.Child;
header.PointerEnter += AddAdorner;
header.PointerLeave += RemoveAdorner;
// This depends on the default tree item template.
// We want to handle events in the item header but exclude events coming from children.
var header = item.FindDescendantOfType<Border>();

Debug.Assert(header != null);

if (header != null)
{
header.PointerEnter += AddAdorner;
header.PointerLeave += RemoveAdorner;
}

item.TemplateApplied -= TreeViewItemTemplateApplied;
}
}
Expand Down