Commit e281672
authored
Detect mouse capture loss during text selection
There may be times when SelectionMouseHandler detects a left mouse button down event on its TextArea, but then immediately the mouse capture is lost, and SelectionMouseHandler does not reset the selection mode.
I noticed this when I started showing a dialog in response to my main window being activated, if I have detected that the file being edited by the user was changed by another process. When I activate my application by clicking on the editor, the SelectionMouseHandler detects this and begins selecting text. But immediately the TextArea loses mouse capture, as in my handler I show a modal dialog. When the user dismisses this dialog, event though the left mouse button is up, moving the mouse around extends the selection as if it were down.
I mimic exactly the approach in the source code for System.Windows.Controls.Primitives.Thumb, the only difference being that here I have to go looking for the SelectionMouseHandler that is associated with the TextArea in the sender parameter. Perhaps there is a more direct way of finding it, though this seems to work for me.1 parent 697ff0d commit e281672
1 file changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
92 | 108 | | |
93 | 109 | | |
94 | 110 | | |
| |||
0 commit comments