Skip to content

Commit 2067f8f

Browse files
committed
GotoDialog and CodeCompletion-window: Fix window being closed when double-clicking the list's scroll bar.
1 parent 785b54a commit 2067f8f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

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
{

0 commit comments

Comments
 (0)