event system!!!

This commit is contained in:
2025-09-25 12:37:06 -04:00
parent 4deeabe611
commit 21f15fb9c5
7 changed files with 255 additions and 50 deletions

View File

@@ -1,11 +1,18 @@
use ui::{core::CursorState, layout::Vec2};
use winit::event::{MouseButton, WindowEvent};
use ui::{
core::{CursorState, Modifiers},
layout::Vec2,
};
use winit::{
event::{MouseButton, WindowEvent},
keyboard::{Key, NamedKey},
};
use crate::testing::Client;
#[derive(Default)]
pub struct Input {
cursor: CursorState,
pub modifiers: Modifiers,
}
impl Input {
@@ -27,6 +34,21 @@ impl Input {
}
WindowEvent::CursorLeft { .. } => {
self.cursor.exists = false;
self.modifiers.clear();
}
WindowEvent::KeyboardInput { event, .. } => {
if let Key::Named(named) = event.logical_key {
let pressed = event.state.is_pressed();
match named {
NamedKey::Control => {
self.modifiers.control = pressed;
}
NamedKey::Shift => {
self.modifiers.shift = pressed;
}
_ => (),
}
}
}
_ => return false,
}