Browse Source

Fix #3574: MMB shortcut to "Decompile to new tab" doesn't work in Search tab

pull/3579/head
Siegfried Pammer 9 months ago
parent
commit
808b6d36db
  1. 2
      ILSpy/Search/SearchPane.xaml
  2. 29
      ILSpy/Search/SearchPane.xaml.cs

2
ILSpy/Search/SearchPane.xaml

@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
</Grid>
</Border>
<ProgressBar x:Name="searchProgressBar" Grid.Row="1" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<ListView Grid.Row="2" BorderThickness="0,1,0,0" HorizontalContentAlignment="Stretch" KeyDown="ListBox_KeyDown"
<ListView Grid.Row="2" BorderThickness="0,1,0,0" HorizontalContentAlignment="Stretch" KeyDown="ListBox_KeyDown" MouseDown="ListBox_MouseDown" MouseUp="ListBox_MouseUp"
MouseDoubleClick="ListBox_MouseDoubleClick" Name="listBox" SelectionMode="Single" controls:SortableGridViewColumn.SortMode="Automatic"
controls:GridViewColumnAutoSize.AutoWidth="40%;40%;20%" BorderBrush="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"
ItemsSource="{Binding Results, ElementName=self}"

29
ILSpy/Search/SearchPane.xaml.cs

@ -167,12 +167,35 @@ namespace ICSharpCode.ILSpy.Search @@ -167,12 +167,35 @@ namespace ICSharpCode.ILSpy.Search
e.Handled = true;
}
private void ListBox_MouseDown(object sender, MouseButtonEventArgs e)
{
var item = listBox.InputHitTest(e.GetPosition(listBox)) as DependencyObject;
while (item != null && item != listBox)
{
if (item is ListBoxItem)
{
listBox.SelectedItem = ((ListBoxItem)item).DataContext;
break;
}
item = VisualTreeHelper.GetParent(item);
}
}
private void ListBox_MouseUp(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Middle)
{
JumpToSelectedItem(inNewTabPage: true);
e.Handled = true;
}
}
void ListBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
e.Handled = true;
JumpToSelectedItem();
JumpToSelectedItem(e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control));
}
else if (e.Key == Key.Up && listBox.SelectedIndex == 0)
{
@ -281,11 +304,11 @@ namespace ICSharpCode.ILSpy.Search @@ -281,11 +304,11 @@ namespace ICSharpCode.ILSpy.Search
}
}
void JumpToSelectedItem()
void JumpToSelectedItem(bool inNewTabPage = false)
{
if (listBox.SelectedItem is SearchResult result)
{
MessageBus.Send(this, new NavigateToReferenceEventArgs(result.Reference));
MessageBus.Send(this, new NavigateToReferenceEventArgs(result.Reference, inNewTabPage));
}
}

Loading…
Cancel
Save