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 #3333: Clicking does not select in Assemblies pane when it doesn' have focus #3335

Merged
merged 1 commit into from
Nov 17, 2024
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
6 changes: 4 additions & 2 deletions ILSpy/AssemblyTree/AssemblyListPane.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.TreeView;

using TomsToolbox.Wpf;
using TomsToolbox.Wpf.Composition.AttributedModel;

namespace ICSharpCode.ILSpy.AssemblyTree
Expand Down Expand Up @@ -56,7 +57,7 @@ protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
var selected = model.SelectedItem;
if (selected != null)
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Background, () => {
this.BeginInvoke(DispatcherPriority.Background, () => {
ScrollIntoView(selected);
this.SelectedItem = selected;
});
Expand All @@ -69,7 +70,8 @@ protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)

if (SelectedItem is SharpTreeNode selectedItem)
{
FocusNode(selectedItem);
// defer focusing, so it does not interfere with selection via mouse click
this.BeginInvoke(() => FocusNode(selectedItem));
}
else
{
Expand Down
1 change: 1 addition & 0 deletions ILSpy/AssemblyTree/AssemblyTreeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ public void SelectNodes(IEnumerable<SharpTreeNode> nodes)
private void JumpToReference(object? sender, NavigateToReferenceEventArgs e)
{
JumpToReferenceAsync(e.Reference, e.InNewTabPage).HandleExceptions();
IsActive = true;
}

/// <summary>
Expand Down
9 changes: 6 additions & 3 deletions ILSpy/Controls/TreeView/SharpTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

using ICSharpCode.ILSpyX.TreeView;

using TomsToolbox.Wpf;

namespace ICSharpCode.ILSpy.Controls.TreeView
{
public class SharpTreeView : ListView
Expand Down Expand Up @@ -396,17 +398,18 @@ void ExpandRecursively(SharpTreeNode node)
/// </summary>
public void FocusNode(SharpTreeNode node)
{
if (node == null)
throw new ArgumentNullException("node");
ArgumentNullException.ThrowIfNull(node);

ScrollIntoView(node);

// WPF's ScrollIntoView() uses the same if/dispatcher construct, so we call OnFocusItem() after the item was brought into view.
if (this.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
{
OnFocusItem(node);
}
else
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(this.OnFocusItem), node);
this.BeginInvoke(DispatcherPriority.Loaded, () => OnFocusItem(node));
}
}

Expand Down
Loading