use pel::{
input::{KeyboardInput, ModifierKeys, MouseInput},
Context, Events,
};
struct EventHandler;
impl Events for EventHandler {
fn init(&mut self, _ctx: &mut Context) {
println!("Event loop started.");
}
fn window_focus(&mut self, _ctx: &mut Context, focus: bool) {
println!("Window is now {}.", if focus { "focused" } else { "unfocused" });
}
fn window_resized(&mut self, _ctx: &mut Context, size: (usize, usize)) {
println!("Window resized; new size: {:?}.", size);
}
fn cursor_focus(&mut self, _ctx: &mut Context, focus: bool) {
println!("Cursor has {} client area.", if focus { "entered" } else { "left" });
}
fn text_input(&mut self, _ctx: &mut Context, codepoint: char) {
println!("Received text input: char='{}'.", codepoint);
}
fn key_input(&mut self, _ctx: &mut Context, input: KeyboardInput) {
println!("Received raw key input: scancode={:?}.", input);
}
fn mouse_moved(&mut self, _ctx: &mut Context, pos: (usize, usize)) {
println!("Mouse moved; new position: {:?}.", pos);
}
fn mouse_click(&mut self, _ctx: &mut Context, click: MouseInput) {
println!("Mouse button state changed: {:?}.", click);
}
fn mouse_scroll(&mut self, _ctx: &mut Context, delta: f32) {
println!("Mouse scrolled: {}.", delta);
}
fn keyboard_modifiers(&mut self, _ctx: &mut Context, modifiers: ModifierKeys) {
println!("Modifier key state changed: {:?}", modifiers);
}
fn exit_requested(&mut self, _ctx: &mut Context) -> bool {
println!("Window got request to close; accepting.");
true
}
fn exit(&mut self) {
println!("Event loop shutting down.");
}
}
fn main() {
pel::new()
.texture_size(1, 1)
.run(EventHandler);
}