#accessibility #ui

fltk-accesskit

fltk accesskit adapter made to work with the fltk gui crate

4 releases

0.1.3 Jun 14, 2023
0.1.2 Jun 11, 2023
0.1.1 Jun 8, 2023
0.1.0 Jun 6, 2023

#1480 in GUI

MIT license

34KB
753 lines

fltk-accesskit

fltk-accesskit is an fltk accesskit adapter made to work with the fltk gui crate.

Example code:

#![windows_subsystem = "windows"]
use fltk::{prelude::*, *};
use fltk_accesskit::{AccessibilityContext, AccessibleApp};

fn main() {
    let a = app::App::default().with_scheme(app::Scheme::Oxy);
    let mut w = window::Window::default()
        .with_size(400, 300)
        .with_label("Hello fltk-accesskit");
    let col = group::Flex::default()
        .with_size(200, 100)
        .center_of_parent()
        .column();
    let inp = input::Input::default().with_id("inp").with_label("Enter name:");
    let mut btn = button::Button::default().with_label("Greet");
    let out = output::Output::default().with_id("out");
    col.end();
    w.end();
    w.make_resizable(true);
    w.show();

    btn.set_callback(btn_callback);

    let ac = AccessibilityContext::new(
        w,
        vec![Box::new(inp), Box::new(btn), Box::new(out)],
    );

    a.run_with_accessibility(ac).unwrap();
}

fn btn_callback(_btn: &mut button::Button) {
    let inp: input::Input = app::widget_from_id("inp").unwrap();
    let mut out: output::Output = app::widget_from_id("out").unwrap();
    let name = inp.value();
    if name.is_empty() {
        return;
    }
    out.set_value(&format!("Hello {}", name));
}

To use fltk-accesskit, add fltk-accesskit to your Cargo.toml:

[dependencies]
fltk = "1.4"
fltk-accesskit = "0.1.0"

image

Video demo

Dependencies

~14–46MB
~744K SLoC