Focus text_editor at start-up in editor example

This commit is contained in:
Héctor Ramón Jiménez 2024-08-12 02:55:49 +02:00
parent be7d175388
commit 373e887a58
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -1,7 +1,7 @@
use iced::highlighter; use iced::highlighter;
use iced::keyboard; use iced::keyboard;
use iced::widget::{ use iced::widget::{
button, column, container, horizontal_space, pick_list, row, text, self, button, column, container, horizontal_space, pick_list, row, text,
text_editor, tooltip, text_editor, tooltip,
}; };
use iced::{Center, Element, Fill, Font, Subscription, Task, Theme}; use iced::{Center, Element, Fill, Font, Subscription, Task, Theme};
@ -49,6 +49,7 @@ impl Editor {
is_loading: true, is_loading: true,
is_dirty: false, is_dirty: false,
}, },
Task::batch([
Task::perform( Task::perform(
load_file(format!( load_file(format!(
"{}/src/main.rs", "{}/src/main.rs",
@ -56,6 +57,8 @@ impl Editor {
)), )),
Message::FileOpened, Message::FileOpened,
), ),
widget::focus_next(),
]),
) )
} }