From 373e887a5834dbf2272aeaea8f1820ee90698400 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 12 Aug 2024 02:55:49 +0200 Subject: Focus `text_editor` at start-up in `editor` example --- examples/editor/src/main.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'examples/editor/src') diff --git a/examples/editor/src/main.rs b/examples/editor/src/main.rs index 155e74a1..aa07b328 100644 --- a/examples/editor/src/main.rs +++ b/examples/editor/src/main.rs @@ -1,7 +1,7 @@ use iced::highlighter; use iced::keyboard; 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, }; use iced::{Center, Element, Fill, Font, Subscription, Task, Theme}; @@ -49,13 +49,16 @@ impl Editor { is_loading: true, is_dirty: false, }, - Task::perform( - load_file(format!( - "{}/src/main.rs", - env!("CARGO_MANIFEST_DIR") - )), - Message::FileOpened, - ), + Task::batch([ + Task::perform( + load_file(format!( + "{}/src/main.rs", + env!("CARGO_MANIFEST_DIR") + )), + Message::FileOpened, + ), + widget::focus_next(), + ]), ) } -- cgit