mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-01-06 01:44:21 +01:00
input: switch to scanning over raw input events
Calling key_pressed invokes a filter over the entire event list every time, this is much more efficient, which is important when we are handling many key events.
This commit is contained in:
23
src/app.rs
23
src/app.rs
@@ -107,10 +107,25 @@ fn send_initial_filters(damus: &mut Damus, relay_url: &str) {
|
||||
fn try_process_event(damus: &mut Damus, ctx: &egui::Context) -> Result<()> {
|
||||
ctx.input(|i| {
|
||||
let amount = 0.2;
|
||||
if i.key_pressed(egui::Key::Equals) {
|
||||
ctx.set_pixels_per_point(ctx.pixels_per_point() + amount);
|
||||
} else if i.key_pressed(egui::Key::Minus) {
|
||||
ctx.set_pixels_per_point(ctx.pixels_per_point() - amount);
|
||||
|
||||
for event in &i.raw.events {
|
||||
match event {
|
||||
egui::Event::Key {
|
||||
key, pressed: true, ..
|
||||
} => match key {
|
||||
egui::Key::Equals => {
|
||||
ctx.set_pixels_per_point(ctx.pixels_per_point() + amount);
|
||||
}
|
||||
|
||||
egui::Key::Minus => {
|
||||
ctx.set_pixels_per_point(ctx.pixels_per_point() - amount);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
},
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user