Crates.io | egui-typed-input |
lib.rs | egui-typed-input |
version | 0.1.1 |
created_at | 2025-05-21 00:32:10.640538+00 |
updated_at | 2025-08-06 16:09:35.466049+00 |
description | Type safe parsed egui text inputs, with input checking |
homepage | |
repository | https://github.com/TimTheBig/egui_typed_input |
max_upload_size | |
id | 1682715 |
size | 115,119 |
Input checked and type safe parsed egui text inputs, allowing you to have typed inputs and focus on your ux not parsing.
use egui_typed_input::ValText;
fn main() {
let mut alphabetical_order: ValText<Vec<char>, ()> = ValText::new(
// parser
(|str| Ok(str.chars().collect::<Vec<_>>())),
// input validator
(|current_text, input, index| {
if input.chars().all(|c| c.is_ascii_alphabetic()) {
input.chars().all(|c| {
c.to_ascii_lowercase() >= current_text.chars().skip(index.saturating_sub(1)).take(1).last().unwrap_or('a')
})
} else { false }
}),
);
eframe::run_simple_native(
"typed input",
eframe::NativeOptions::default(),
move |ctx, _frame| {
egui::CentralPanel::default().show(ctx, |ui| {
ui.text_edit_singleline(&mut alphabetical_order);
println!("alphabetical_order: {:?}", alphabetical_order.get_val());
});
}
).unwrap();
}