Auto-focus text_input in websocket example

This commit is contained in:
Héctor Ramón Jiménez 2024-05-03 09:25:47 +02:00
parent 15057a05c1
commit 4c658c41e9
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -1,7 +1,9 @@
mod echo;
use iced::alignment::{self, Alignment};
use iced::widget::{button, center, column, row, scrollable, text, text_input};
use iced::widget::{
self, button, center, column, row, scrollable, text, text_input,
};
use iced::{color, Command, Element, Length, Subscription};
use once_cell::sync::Lazy;
@ -29,7 +31,10 @@ enum Message {
impl WebSocket {
fn load() -> Command<Message> {
Command::perform(echo::server::run(), |_| Message::Server)
Command::batch([
Command::perform(echo::server::run(), |_| Message::Server),
widget::focus_next(),
])
}
fn update(&mut self, message: Message) -> Command<Message> {