From 92ceea208f347f3427100b84a65a5d0e130166f8 Mon Sep 17 00:00:00 2001 From: djmil Date: Sat, 31 Aug 2024 20:49:23 +0200 Subject: [PATCH] circles punch: touchscreen support --- src/app.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index 0dd1b52..ac2d422 100644 --- a/src/app.rs +++ b/src/app.rs @@ -21,8 +21,8 @@ pub struct Simulation { impl Default for Simulation { fn default() -> Self { Self { - circles: Vec::new(), circles_count: 2, + circles: Vec::new(), colors: Vec::new(), } } @@ -122,10 +122,11 @@ impl eframe::App for Simulation { ); } - let (hover_pos, any_down, any_released) = ctx.input(|input| ( + let (hover_pos, any_down, any_released, any_pressed) = ctx.input(|input| ( input.pointer.hover_pos(), input.pointer.any_down(), - input.pointer.any_released() + input.pointer.any_released(), + input.pointer.any_pressed() )); if let Some(mousepos) = hover_pos { @@ -138,7 +139,7 @@ impl eframe::App for Simulation { Stroke{width: 1.5, color: Color32::from_rgb(255, 0, 0)}); } - if any_released { + if any_released || any_pressed { circle.v += d.normalized() * (d.length() / circle.r) * 8.0; } }