pub struct VirtualKeyboard { /* private fields */ }Expand description
§A Keyboard, that can be drawn in egui.
By default holds mobile version of QWERTY, Numeric & Symbols layouts.
Needs to hook into raw input with bump_events.
Example use:
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()))),
)
}Implementations§
Source§impl VirtualKeyboard
impl VirtualKeyboard
pub fn clear_layouts(&mut self)
Sourcepub fn switch_layout(&mut self, name: &str)
pub fn switch_layout(&mut self, name: &str)
Switches to Layout with provided name (if exists)
Sourcepub fn with_butyon_spacing(self, spacing: Vec2) -> Self
pub fn with_butyon_spacing(self, spacing: Vec2) -> Self
Use provided button height instead of default interact_size.x * 0.9
Use provided button height instead of default interact_size.x * 0.9
Use provided button width range instead of icon_width..=interact_size.x
Sourcepub fn bump_events(&mut self, _ctx: &Context, raw_input: &mut RawInput)
pub fn bump_events(&mut self, _ctx: &Context, raw_input: &mut RawInput)
Adds keyboard events to raw input
Sourcepub fn show(&mut self, ui: &mut Ui)
pub fn show(&mut self, ui: &mut Ui)
Add Keyboard to ui. Recommended to use in separate window or panel.
pub fn layout_name(&self) -> String
Trait Implementations§
Source§impl Clone for VirtualKeyboard
impl Clone for VirtualKeyboard
Source§fn clone(&self) -> VirtualKeyboard
fn clone(&self) -> VirtualKeyboard
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VirtualKeyboard
impl Debug for VirtualKeyboard
Source§impl Default for VirtualKeyboard
impl Default for VirtualKeyboard
Source§impl<'de> Deserialize<'de> for VirtualKeyboard
impl<'de> Deserialize<'de> for VirtualKeyboard
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for VirtualKeyboard
impl !RefUnwindSafe for VirtualKeyboard
impl Send for VirtualKeyboard
impl Sync for VirtualKeyboard
impl Unpin for VirtualKeyboard
impl !UnwindSafe for VirtualKeyboard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more