Skip to content

scroll_with_delta doesn't work #2783

@marcin-serwin

Description

@marcin-serwin

Describe the bug

scroll_with_delta doesn't seem to work.

To Reproduce

Steps to reproduce the behavior:

  1. Create an app with eframe.
  2. Copy the scroll_with_delta example from documentation.
  3. Click Scroll down button.
  4. See that nothing happens.
use eframe::egui::{self, Vec2};

fn main() -> Result<(), eframe::Error> {
    eframe::run_native(
        "My egui App",
        eframe::NativeOptions::default(),
        Box::new(|_cc| Box::new(MyApp {})),
    )
}

struct MyApp {}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            let mut scroll_delta = Vec2::ZERO;
            if ui.button("Scroll down").clicked() {
                scroll_delta.y -= 64.0; // move content up
            }
            egui::ScrollArea::vertical().show(ui, |ui| {
                ui.scroll_with_delta(scroll_delta);
                for i in 0..1000 {
                    ui.label(format!("Item {}", i));
                }
            });
        });
    }
}

Expected behavior

Content scrolls down.

Screenshots

untitled.webm

Desktop (please complete the following information):

  • OS: GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions