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

Scroll should try to show the focused widget on focus change #1974

Closed
maan2003 opened this issue Sep 16, 2021 · 3 comments · Fixed by #1976
Closed

Scroll should try to show the focused widget on focus change #1974

maan2003 opened this issue Sep 16, 2021 · 3 comments · Fixed by #1976

Comments

@maan2003
Copy link
Collaborator

Whenever focus is changed, scroll should pan to the widget with the focus. in this example when focusing the textboxes outside the viewport, scroll doesn't move

example to test
use druid::widget::{Flex, Padding, TextBox};
use druid::{AppLauncher, Widget, WidgetExt, WindowDesc};

pub fn main() {
    let window = WindowDesc::new(build_widget());
    AppLauncher::with_window(window)
        .log_to_console()
        .launch("".to_string())
        .expect("launch failed");
}

fn build_widget() -> impl Widget<String> {
    let mut col = Flex::column();
    for _ in 0..30 {
        col.add_child(Padding::new(3.0, TextBox::new()));
    }
    col.scroll()
}
@xarvic
Copy link
Collaborator

xarvic commented Sep 17, 2021

Maybe this could be done with a notification. Something like ScrollTo: Selector<Rect>. Either with global coordinates or by updating the notification in every WidgetPod it is passed trough.

@maan2003
Copy link
Collaborator Author

global coordinates should be fine. Nested Scrolls will be a good testcase

@xarvic
Copy link
Collaborator

xarvic commented Sep 18, 2021

Maybe this could be done with a notification. Something like ScrollTo: Selector<Rect>.

I just noticed that FocusChanged is a lifecycle event, hence we can`t send Notifications. We could use Commands but this feels wrong.

@xarvic xarvic linked a pull request Sep 18, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants