Add vertical scrollbar to multiline_text_input example#25066
Open
Supremesv715 wants to merge 3 commits into
Open
Add vertical scrollbar to multiline_text_input example#25066Supremesv715 wants to merge 3 commits into
Supremesv715 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Objective
Fixes #24646
The multiline_text_input example's scrollable EditableText input has no scrollbar, making it unclear how much content is above/below the visible area.
Solution
Added EditableText::content_size, exposing the full text layout size (previously a private local in update_editable_text_layout) so external code can compute how much of the content is visible.
Built a self-contained track + thumb scrollbar in the example, synced to EditableText::viewport/content_size:
Thumb size/position reflects the visible fraction and scroll offset.
Thumb is draggable and writes back to viewport.offset.y.
Hidden when the full layout already fits in the viewport.
No TabIndex, so it's unreachable via Tab navigation and can't take input focus, per the issue's requirements.
The existing bevy_ui_widgets::Scrollbar widget wasn't reusable here since it's hard-wired to ScrollPosition, which EditableText doesn't use.
Testing
cargo build -p bevy_text -p bevy_ui — passes.
Manually ran the example: typed past the visible line count to confirm the thumb appears/resizes, dragged the thumb to confirm it scrolls the input, deleted text back down to confirm the thumb hides, and tabbed through the UI to confirm the scrollbar is never focused.