1use macroquad::prelude::*;
2use flowquad::prelude::*;
3
4#[macroquad::main("Images!")]
5async fn main() {
6 let poppins = load_ttf_font("examples/poppins.ttf").await.unwrap();
7 let label = Label::new("Text Inputs!".to_string(), Color::new(0.05, 0.05, 0.1, 1.0), Color::new(0.5, 0.5, 1.0, 1.0), Some(poppins.clone()), 48.0);
8 let textinp = TextInput::new(512.0, 64.0, Color::new(0.05, 0.05, 0.1, 1.0), Color::new(0.5, 0.5, 1.0, 1.0), Some(poppins.clone()));
9 let textinp2 = TextInput::new(512.0, 64.0, Color::new(0.05, 0.05, 0.1, 1.0), Color::new(0.5, 0.5, 1.0, 1.0), Some(poppins.clone()));
10 let mut container = Container::new(Direction::Vertical, Align::Center, 20.0, Color::new(0.05, 0.05, 0.1, 1.0), None, None);
11 container.add_child(Box::new(label));
12 container.add_child(Box::new(textinp));
13 container.add_child(Box::new(textinp2));
14
15 let mut previous_text = String::new();
16 let mut previous_text2 = String::new();
17
18 loop {
19 clear_background(Color::new(0.05, 0.05, 0.1, 1.0));
20
21 container.update(screen_width() / 2.0 - container.width() / 2.0, screen_height() / 2.0 - container.height() / 2.0);
22 container.render(screen_width() / 2.0 - container.width() / 2.0, screen_height() / 2.0 - container.height() / 2.0);
23 let textinp = container.get_child_as::<TextInput>(1).unwrap();
26 let textinp2 = container.get_child_as::<TextInput>(2).unwrap();
27 if textinp.get_text() != previous_text {
28 println!("Text: {}", textinp.get_text());
29 previous_text = textinp.get_text();
30 }
31 if textinp2.get_text() != previous_text2 {
32 println!("Text2: {}", textinp2.get_text());
33 previous_text2 = textinp2.get_text();
34 }
35
36 next_frame().await;
37 }
38}