Closed chaojian-zhang closed 1 year ago
The problem is that the outer ScrollViewer is trying to scroll the editor into view. Meanwhile, AvalonEdit has detected the mouse being clicked and is trying to figure out if it needs to start or extend a selection. The editor actually gets scrolled (thus, the jumpiness), and then AvalonEdit does set a selection.
Someone else having the same problem (but not with AvalonEdit):
https://stackoverflow.com/questions/20842630/wpf-stackpanel-jumps
That article suggests handling the RequestBringIntoView and setting e.Handled to true. I tried this (on either the TextEditor or TextArea) and it seemed to work.
Just as with your other report - I'm not sure why TextBox doesn't have this problem, I looked at the source code and didn't see a handler for RequestBringIntoView, but that might take a lot of time to figure out.
Thanks for the reply!
I have tried your solution and it works.
You can close this issue, yes?
Scenario: When using TextEdit inside a large page which already has a scroll viewer, and when the overall height of the TextEdit exceeds visible area, when LMB mouse click on the TextEdit and causing it to has focus, the TextEdit control will force the containing scroll viewer to jump and select (unexpectedly) a range of text.
Expectation: Don't jump, don't do anything to the containing scrollviewer. For instance, when using regular TextBox, there is no such issue.
Demonstration:
https://user-images.githubusercontent.com/7077098/228344050-27272fd8-fc2d-4a08-94e1-540ec5e9b1c7.mp4
The TextEdit control forces the scroll viewer to scroll and cause itself to select a range of text when gaining focus!
Source:
Expected behavior:
https://user-images.githubusercontent.com/7077098/228344459-e2f10bca-bb5b-4a03-bc76-ffcfd2316954.mp4
When using old good text box, there is no such issue!
Source: