From 76b9e8b7bf4b5a57a6cac97e63fbf3118d0fa389 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 4 Oct 2023 11:13:58 -0600 Subject: [PATCH] Focus authentication text box --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 0cf0458..7e872ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -282,6 +282,7 @@ pub struct App { selected_session: String, socket_state: SocketState, input_state: InputState, + text_input_id: widget::Id, } /// Implement [`cosmic::Application`] to integrate with COSMIC. @@ -330,6 +331,7 @@ impl cosmic::Application for App { socket_state: SocketState::Pending, //TODO: set to pending until socket is open? input_state: InputState::Username, + text_input_id: widget::Id::unique(), }, Command::perform( async { @@ -355,6 +357,8 @@ impl cosmic::Application for App { } Message::Input(input_state) => { self.input_state = input_state; + //TODO: only focus text input on changes to the page + return widget::text_input::focus(self.text_input_id.clone()); } Message::Session(selected_session) => { self.selected_session = selected_session; @@ -477,6 +481,7 @@ impl cosmic::Application for App { .width(iced::Length::Fixed(400.0)); column = column.push(widget::text(prompt)); let text_input = widget::text_input("", &value) + .id(self.text_input_id.clone()) .on_input(|value| { Message::Input(InputState::Auth { secret: *secret,