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<()> {
|
fn try_process_event(damus: &mut Damus, ctx: &egui::Context) -> Result<()> {
|
||||||
ctx.input(|i| {
|
ctx.input(|i| {
|
||||||
let amount = 0.2;
|
let amount = 0.2;
|
||||||
if i.key_pressed(egui::Key::Equals) {
|
|
||||||
ctx.set_pixels_per_point(ctx.pixels_per_point() + amount);
|
for event in &i.raw.events {
|
||||||
} else if i.key_pressed(egui::Key::Minus) {
|
match event {
|
||||||
ctx.set_pixels_per_point(ctx.pixels_per_point() - amount);
|
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