Skip to content

Commit 808b6d3

Browse files
Fix #3574: MMB shortcut to "Decompile to new tab" doesn't work in Search tab
1 parent 52b753c commit 808b6d3

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

ILSpy/Search/SearchPane.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</Grid>
4949
</Border>
5050
<ProgressBar x:Name="searchProgressBar" Grid.Row="1" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
51-
<ListView Grid.Row="2" BorderThickness="0,1,0,0" HorizontalContentAlignment="Stretch" KeyDown="ListBox_KeyDown"
51+
<ListView Grid.Row="2" BorderThickness="0,1,0,0" HorizontalContentAlignment="Stretch" KeyDown="ListBox_KeyDown" MouseDown="ListBox_MouseDown" MouseUp="ListBox_MouseUp"
5252
MouseDoubleClick="ListBox_MouseDoubleClick" Name="listBox" SelectionMode="Single" controls:SortableGridViewColumn.SortMode="Automatic"
5353
controls:GridViewColumnAutoSize.AutoWidth="40%;40%;20%" BorderBrush="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"
5454
ItemsSource="{Binding Results, ElementName=self}"

ILSpy/Search/SearchPane.xaml.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,35 @@ void ListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
167167
e.Handled = true;
168168
}
169169

170+
private void ListBox_MouseDown(object sender, MouseButtonEventArgs e)
171+
{
172+
var item = listBox.InputHitTest(e.GetPosition(listBox)) as DependencyObject;
173+
while (item != null && item != listBox)
174+
{
175+
if (item is ListBoxItem)
176+
{
177+
listBox.SelectedItem = ((ListBoxItem)item).DataContext;
178+
break;
179+
}
180+
item = VisualTreeHelper.GetParent(item);
181+
}
182+
}
183+
184+
private void ListBox_MouseUp(object sender, MouseButtonEventArgs e)
185+
{
186+
if (e.ChangedButton == MouseButton.Middle)
187+
{
188+
JumpToSelectedItem(inNewTabPage: true);
189+
e.Handled = true;
190+
}
191+
}
192+
170193
void ListBox_KeyDown(object sender, KeyEventArgs e)
171194
{
172195
if (e.Key == Key.Return)
173196
{
174197
e.Handled = true;
175-
JumpToSelectedItem();
198+
JumpToSelectedItem(e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control));
176199
}
177200
else if (e.Key == Key.Up && listBox.SelectedIndex == 0)
178201
{
@@ -281,11 +304,11 @@ async void StartSearch(string searchTerm)
281304
}
282305
}
283306

284-
void JumpToSelectedItem()
307+
void JumpToSelectedItem(bool inNewTabPage = false)
285308
{
286309
if (listBox.SelectedItem is SearchResult result)
287310
{
288-
MessageBus.Send(this, new NavigateToReferenceEventArgs(result.Reference));
311+
MessageBus.Send(this, new NavigateToReferenceEventArgs(result.Reference, inNewTabPage));
289312
}
290313
}
291314

0 commit comments

Comments
 (0)