Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
textInsets
property that allows insetting the drawn text further than other drawn content in the view.This works in addition to the
edgeInsets
property, and only effects where text is drawn. This enables adding a padded area where text is not drawn, and selections are not drawn, and further inset the text from that edge.This is useful when adding trailing padding to a text view that is not wrapping lines. In a case like that, the textview needs to have a larger width than just the text, but also needs to draw the selection rect in that padded area. To achieve this, the text inset would be set to the padded area.
Related Issues
Checklist
Screenshots
Text insets and edge insets have left and right set to 30. All content is inset by 30px and the text is further inset by another 30px on the right side.
Screen.Recording.2025-01-12.at.1.58.42.PM.mov
An example of negative text insets on top of positive edge insets, showing it works as expected.
Screen.Recording.2025-01-12.at.1.57.42.PM.mov
No wrapping lines, text inset is >0 on the right edge, meaning the textview has some room to scroll after the text, while still drawing the selection rect in some of that padded area.
Screen.Recording.2025-01-12.at.1.59.14.PM.mov
The updated example app with two new controls: