Skip to content

Commit ec27566

Browse files
authored
Merge pull request #96 from jimfoye/patch-1
Detect mouse capture loss during text selection
2 parents 93ab445 + 9371075 commit ec27566

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ public SelectionMouseHandler(TextArea textArea)
8989
this.textArea = textArea;
9090
}
9191

92+
static SelectionMouseHandler()
93+
{
94+
EventManager.RegisterClassHandler(typeof(TextArea), Mouse.LostMouseCaptureEvent, new MouseEventHandler(OnLostMouseCapture));
95+
}
96+
97+
private static void OnLostMouseCapture(object sender, MouseEventArgs e)
98+
{
99+
TextArea textArea = (TextArea)sender;
100+
if (Mouse.Captured != textArea)
101+
{
102+
SelectionMouseHandler handler = textArea.DefaultInputHandler.MouseSelection as SelectionMouseHandler;
103+
if (handler != null)
104+
handler.mode = SelectionMode.None;
105+
}
106+
}
107+
92108
public TextArea TextArea {
93109
get { return textArea; }
94110
}

0 commit comments

Comments
 (0)