can type into a box while still receiving buttons
parent
25e99fbf93
commit
173bf045d9
20
src/gui.rs
20
src/gui.rs
|
|
@ -1,4 +1,5 @@
|
||||||
use iced::widget::{button, column, text};
|
use iced::widget::{button, column, text};
|
||||||
|
use iced::widget::text_input;
|
||||||
use iced::executor;
|
use iced::executor;
|
||||||
use iced::keyboard;
|
use iced::keyboard;
|
||||||
use iced::subscription;
|
use iced::subscription;
|
||||||
|
|
@ -42,6 +43,8 @@ struct Main {
|
||||||
keys_already_down: Vec<iced::keyboard::KeyCode>,
|
keys_already_down: Vec<iced::keyboard::KeyCode>,
|
||||||
keys_up: Vec<iced::keyboard::KeyCode>,
|
keys_up: Vec<iced::keyboard::KeyCode>,
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
|
input_text_entry_instruction: String,
|
||||||
|
input_text_entry_value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Flags {
|
struct Flags {
|
||||||
|
|
@ -70,6 +73,8 @@ struct Stick {
|
||||||
enum Message {
|
enum Message {
|
||||||
EventOccurred(iced_native::Event),
|
EventOccurred(iced_native::Event),
|
||||||
Tick,
|
Tick,
|
||||||
|
InputTextEntryUpdate(String),
|
||||||
|
InputTextEntrySubmission,
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
Left,
|
Left,
|
||||||
|
|
@ -221,6 +226,8 @@ impl Application for Main {
|
||||||
keys_newly_down: vec![],
|
keys_newly_down: vec![],
|
||||||
keys_already_down: vec![],
|
keys_already_down: vec![],
|
||||||
keys_up: vec![],
|
keys_up: vec![],
|
||||||
|
input_text_entry_instruction: String::from(""),
|
||||||
|
input_text_entry_value: String::from(""),
|
||||||
}, Command::none())
|
}, Command::none())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,6 +240,13 @@ impl Application for Main {
|
||||||
Message::Tick => {
|
Message::Tick => {
|
||||||
self.exchange();
|
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() => {
|
Message::EventOccurred(event) if self.configuring.is_some() => {
|
||||||
match event {
|
match event {
|
||||||
iced::event::Event::Keyboard(keyboard::Event::KeyPressed{
|
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),
|
button(text(controller_button_to_string(Message::R, self.inputs.r))).on_press(Message::R),
|
||||||
text(self.ntfy1.clone()).size(50),
|
text(self.ntfy1.clone()).size(50),
|
||||||
text(self.ntfy2.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)
|
.padding(20)
|
||||||
.align_items(Alignment::Center)
|
.align_items(Alignment::Center)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue