Browse Source

IconBarMargin: Fixed cancelling drag'n'drop using Escape.

pull/1/head
Daniel Grunwald 15 years ago
parent
commit
0d24b46bbe
  1. 16
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarMargin.cs

16
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarMargin.cs

@ -141,8 +141,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
dragDropBookmark = bm; dragDropBookmark = bm;
dragDropStartPoint = dragDropCurrentPoint = e.GetPosition(this).Y; dragDropStartPoint = dragDropCurrentPoint = e.GetPosition(this).Y;
if (TextView != null) if (TextView != null) {
TextView.PreviewKeyDown += TextView_PreviewKeyDown; TextArea area = TextView.Services.GetService(typeof(TextArea)) as TextArea;
if (area != null)
area.PreviewKeyDown += TextArea_PreviewKeyDown;
}
} }
void CancelDragDrop() void CancelDragDrop()
@ -150,14 +153,17 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (dragDropBookmark != null) { if (dragDropBookmark != null) {
dragDropBookmark = null; dragDropBookmark = null;
dragStarted = false; dragStarted = false;
if (TextView != null) if (TextView != null) {
TextView.PreviewKeyDown -= TextView_PreviewKeyDown; TextArea area = TextView.Services.GetService(typeof(TextArea)) as TextArea;
if (area != null)
area.PreviewKeyDown -= TextArea_PreviewKeyDown;
}
ReleaseMouseCapture(); ReleaseMouseCapture();
InvalidateVisual(); InvalidateVisual();
} }
} }
void TextView_PreviewKeyDown(object sender, KeyEventArgs e) void TextArea_PreviewKeyDown(object sender, KeyEventArgs e)
{ {
// any key press cancels drag'n'drop // any key press cancels drag'n'drop
CancelDragDrop(); CancelDragDrop();

Loading…
Cancel
Save