egui-keybinds

Crates.ioegui-keybinds
lib.rsegui-keybinds
version3.3.8
sourcesrc
created_at2023-02-10 05:57:28.491685
updated_at2023-03-18 02:46:02.213562
descriptionkeybinding system developed for EGUI
homepage
repositoryhttps://github.com/TheRacc2/egui-keybinds
max_upload_size
id781662
size89,687
Liam James (TheRacc2)

documentation

README

egui-keybinds

designed for ease-of-use, egui-keybinds provides keybinding functionality to egui

Example

use egui::{CentralPanel, Context, Widget};
use egui_keybinds::{KeyBind, KeyBindWidget, KeyCode};

struct Gui {
    key1: KeyBind,
    key2: KeyBind,
}

impl Gui {
    fn new() -> Self {
        Self {
            key1: KeyBind::new(Some(KeyCode::A), vec![]),
            key2: KeyBind::new(Some(KeyCode::B), vec![]),
        }
    }
}

impl eframe::App for Gui {
    fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
        CentralPanel::default().show(ctx, |ui| {
            ui.label("Example keybind 1");
            KeyBindWidget::new(&mut self.key1).ui(ui);

            ui.label("Example keybind 2");
            KeyBindWidget::new(&mut self.key2).ui(ui);
        });
    }
}

fn main() {
    eframe::run_native(
        "testing",
        Default::default(),
        Box::new(|_| Box::new(Gui::new())),
    )
    .unwrap();
}

Add to your project

run cargo add egui-keybinds in your terminal of choice while CD'd into the root directory of your project.

Commit count: 28

cargo fmt