Skip to content

How to scroll to a particular button from outside the scrollarea? #4698

Discussion options

You must be logged in to vote

There is the method Response::scroll_to_me that does that. However, when using show_rows instead of show, the rows out of view are not run at all, so you first need to bring the row you want into view using vertical_scroll_offset, so its response gets created and you can scroll to it, although technically you only need the scroll_to_me part after that if you want to use the Align to get the row where you want (top, center etc). Here's an example:

        egui::CentralPanel::default().show(ctx, |ui| {
            let total_rows = 10_000;
            let text_style = egui::TextStyle::Body;
            let row_height = ui.text_style_height(&text_style);
            let spacing = ui.spacing().i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@UnknownSuperficialNight
Comment options

Answer selected by UnknownSuperficialNight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants