form/
form.rs

1#![windows_subsystem = "windows"]
2
3use fltk::{prelude::*, *};
4use fltk_accesskit::{builder, AccessibleApp};
5
6fn main() {
7    let a = app::App::default().with_scheme(app::Scheme::Oxy);
8    let mut w = window::Window::default()
9        .with_size(400, 300)
10        .with_label("Hello fltk-accesskit");
11    let col = group::Flex::default()
12        .with_size(200, 100)
13        .center_of_parent()
14        .column();
15    let _inp = input::Input::default()
16        .with_id("inp")
17        .with_label("Enter name:");
18    let mut btn = button::Button::default().with_label("Greet");
19    let _out = output::Output::default().with_id("out");
20    col.end();
21    w.end();
22    w.make_resizable(true);
23    w.show();
24
25    btn.set_callback(btn_callback);
26
27    let ac = builder(w).attach();
28
29    a.run_with_accessibility(ac).unwrap();
30}
31
32fn btn_callback(_btn: &mut button::Button) {
33    let inp: input::Input = app::widget_from_id("inp").unwrap();
34    let mut out: output::Output = app::widget_from_id("out").unwrap();
35    let name = inp.value();
36    if name.is_empty() {
37        return;
38    }
39    out.set_value(&format!("Hello {}", name));
40}