diff --git a/src/gui.rs b/src/gui.rs index 636540d..b383472 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,4 +1,5 @@ use iced::widget::{button, column, text}; +use iced::widget::text_input; use iced::executor; use iced::keyboard; use iced::subscription; @@ -42,6 +43,8 @@ struct Main { keys_already_down: Vec, keys_up: Vec, flags: Flags, + input_text_entry_instruction: String, + input_text_entry_value: String, } struct Flags { @@ -70,6 +73,8 @@ struct Stick { enum Message { EventOccurred(iced_native::Event), Tick, + InputTextEntryUpdate(String), + InputTextEntrySubmission, Up, Down, Left, @@ -221,6 +226,8 @@ impl Application for Main { keys_newly_down: vec![], keys_already_down: vec![], keys_up: vec![], + input_text_entry_instruction: String::from(""), + input_text_entry_value: String::from(""), }, Command::none()) } @@ -233,6 +240,13 @@ impl Application for Main { Message::Tick => { self.exchange(); }, + Message::InputTextEntryUpdate(payload) => { + self.input_text_entry_value = payload; + }, + Message::InputTextEntrySubmission => { + eprintln!("input text entry pushed: {}", self.input_text_entry_value); + self.input_text_entry_value = String::from(""); // TODO + }, Message::EventOccurred(event) if self.configuring.is_some() => { match event { iced::event::Event::Keyboard(keyboard::Event::KeyPressed{ @@ -330,6 +344,12 @@ impl Application for Main { button(text(controller_button_to_string(Message::R, self.inputs.r))).on_press(Message::R), text(self.ntfy1.clone()).size(50), text(self.ntfy2.clone()).size(50), + text_input( + &self.input_text_entry_instruction, + &self.input_text_entry_value, + Message::InputTextEntryUpdate + ) + .on_submit(Message::InputTextEntrySubmission), ] .padding(20) .align_items(Alignment::Center)