Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TextBox.ScrollToLine #13274

Merged
merged 2 commits into from
Oct 24, 2023
Merged

Add TextBox.ScrollToLine #13274

merged 2 commits into from
Oct 24, 2023

Conversation

mgnslndh
Copy link
Contributor

@mgnslndh mgnslndh commented Oct 16, 2023

What does the pull request do?

Adds the method ScrollToLine to the TextBox control.

What is the current behavior?

No obvious API for moving the caret to a specific line. This is not "compatible" with WPF.

What is the updated/expected behavior with this PR?

  • Calling ScrollToLine with a line index will move the caret index to the first position on the specified line index.
  • There are two new test cases in TextBoxTests.cs

How was the solution implemented (if it's not obvious)?

ScrollToLine will get the TextLine object from the collection and use the TextPresenter.MoveCaretToTextPosition API to move the caret.

Perhaps this is a bit naive implementation. The WPF implementation gets a bounding rectangle and brings that into view.

Checklist

Unsure if this method requires updated docs since not everything is included in the docs. Happy to do so if suggested.

Breaking changes

None that I know of.

Fixed issues

Addresses #3036 at least partially. It would be nice with convenience API:s like ScrollToHome and ScrollToEnd. Those would delegate to existing internal API or to the same API on the ScrollViewer.

I'll leave it to the maintainers to decide if #3036 can be closed or not.

@jmacato jmacato requested a review from Gillibald October 16, 2023 22:42
@Gillibald
Copy link
Contributor

We need a test for Arabic text as well so right to left is also covered.

@mgnslndh
Copy link
Contributor Author

Thanks @Gillibald! Please consider adding the hacktoberfest-accepted label when/if PR gets merged.

@Gillibald Gillibald added this pull request to the merge queue Oct 24, 2023
@Gillibald Gillibald added backported-11.0.x backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch and removed backported-11.0.x labels Oct 24, 2023
Merged via the queue into AvaloniaUI:master with commit c261a60 Oct 24, 2023
5 checks passed
maxkatz6 pushed a commit that referenced this pull request Dec 5, 2023
* Add TextBox.ScrollToLine #3036

* Test data in arabic for RTL testing
@maxkatz6 maxkatz6 added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants