4 releases
new 0.1.3 | Jan 7, 2025 |
---|---|
0.1.2 | Jan 7, 2025 |
0.1.1 | Jan 5, 2025 |
0.1.0 | Jan 2, 2025 |
#426 in Hardware support
261 downloads per month
42KB
1K
SLoC
VirtualKeyboard for egui
Currently use of SoftKeyboard on native android with egui & eframe is... "Slightly difficult"
And to make TextEdit from egui usable on android, this workaround was created
Example use with egui & eframe:
use egui_virtual_keyboard::VirtualKeyboard;
pub struct ExampleApp {
label: String,
keyboard: VirtualKeyboard,
}
impl Default for ExampleApp {
fn default() -> Self {
Self {
label: "Hello World!".to_owned(),
keyboard: Default::default(),
}
}
}
impl eframe::App for ExampleApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Write something: ");
ui.text_edit_singleline(&mut self.label);
});
});
let scr_size = ctx.screen_rect().size();
egui::Window::new("KBD").show(ctx, |ui| {
self.keyboard.show(ui);
});
}
fn raw_input_hook(&mut self, ctx: &egui::Context, raw_input: &mut egui::RawInput) {
self.keyboard.bump_events(ctx, raw_input);
}
}
fn main() -> eframe::Result {
let native_options = eframe::NativeOptions::default();
eframe::run_native(
"eframe template",
native_options,
Box::new(|_cc| Ok(Box::new(ExampleApp::default()))),
)
}
Dependencies
~4.5–10MB
~104K SLoC