commit 8663851e7e49223f667b9de6cafc91b3a1c0e2b8
parent cf2a832a5e740116b4dc3444409499441109cb2d
Author: William Casarin <jb55@jb55.com>
Date: Fri, 17 May 2024 22:53:35 -0500
input: handle raw events
Diffstat:
M | src/app.rs | | | 53 | ++++++++++++++++++++++++++++++++--------------------- |
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/src/app.rs b/src/app.rs
@@ -104,30 +104,41 @@ 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;
-
- 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);
- }
-
- _ => {}
- },
-
+fn handle_key_events(input: &egui::InputState, damus: &mut Damus, ctx: &egui::Context) {
+ let amount = 0.2;
+
+ for event in &input.raw.events {
+ if let egui::Event::Key {
+ key, pressed: true, ..
+ } = event
+ {
+ 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);
+ }
+ egui::Key::J => {
+ damus.select_down();
+ }
+ egui::Key::K => {
+ damus.select_up();
+ }
+ egui::Key::H => {
+ damus.select_left();
+ }
+ egui::Key::L => {
+ damus.select_left();
+ }
_ => {}
}
}
- });
+ }
+}
+
+fn try_process_event(damus: &mut Damus, ctx: &egui::Context) -> Result<()> {
+ ctx.input(|i| handle_key_events(i, damus, ctx));
let ctx2 = ctx.clone();
let wakeup = move || {