Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 2fdf239

Browse files
committed
GotoDialog and CodeCompletion-window: Fix window being closed when double-clicking the list's scroll bar.
1 parent deb5126 commit 2fdf239

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System.Windows.Documents;
2727
using System.Windows.Input;
2828
using System.Linq;
29+
using ICSharpCode.AvalonEdit.Utils;
2930

3031
namespace ICSharpCode.AvalonEdit.CodeCompletion
3132
{
@@ -180,8 +181,11 @@ protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
180181
{
181182
base.OnMouseDoubleClick(e);
182183
if (e.ChangedButton == MouseButton.Left) {
183-
e.Handled = true;
184-
RequestInsertion(e);
184+
// only process double clicks on the ListBoxItems, not on the scroll bar
185+
if (ExtensionMethods.VisualAncestorsAndSelf(e.OriginalSource as DependencyObject).TakeWhile(obj => obj != this).Any(obj => obj is ListBoxItem)) {
186+
e.Handled = true;
187+
RequestInsertion(e);
188+
}
185189
}
186190
}
187191

src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ExtensionMethods.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ public static Rect ToWpf(this System.Drawing.Rectangle rect)
209209
}
210210
#endregion
211211

212+
public static IEnumerable<DependencyObject> VisualAncestorsAndSelf(this DependencyObject obj)
213+
{
214+
while (obj != null) {
215+
yield return obj;
216+
obj = VisualTreeHelper.GetParent(obj);
217+
}
218+
}
219+
212220
[Conditional("DEBUG")]
213221
public static void CheckIsFrozen(Freezable f)
214222
{

src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,13 @@ void okButtonClick(object sender, RoutedEventArgs e)
459459
Close();
460460
}
461461
}
462+
463+
void ListItem_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
464+
{
465+
if (e.ClickCount == 2) {
466+
okButtonClick(sender, e);
467+
}
468+
}
462469
}
463470

464471
public class GotoUtils

src/Main/Base/Project/Src/Gui/Dialogs/GotoDialog.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@
4646
HorizontalAlignment="Stretch"
4747
VerticalAlignment="Stretch"
4848
Margin="8,4,8,4"
49-
Name="listBox"
50-
MouseDoubleClick="okButtonClick">
49+
Name="listBox">
5150
<ListBox.ItemTemplate>
5251
<DataTemplate>
53-
<StackPanel Orientation="Horizontal">
52+
<StackPanel Orientation="Horizontal" MouseLeftButtonDown="ListItem_MouseLeftButtonDown">
5453
<Image Source="{Binding ImageSource}" Style="{StaticResource ListItemImageStyle}"/>
5554
<TextBlock Text="{Binding Text}" Margin="4,0,0,0" Style="{StaticResource ListItemTextStyle}"/>
5655
</StackPanel>

0 commit comments

Comments
 (0)