diff options
author | 2024-04-30 11:49:50 -0400 | |
---|---|---|
committer | 2024-09-09 23:45:15 +0200 | |
commit | 9edd805c0257cf360d7f9c0ee741c3508bdf8582 (patch) | |
tree | 7f0379c6cee6bfbe04942729e27a92fcc488dc99 /core/src/mouse | |
parent | 630f3525ddc58f1ee8dfec2f7567f52ea77eaa6e (diff) | |
download | iced-9edd805c0257cf360d7f9c0ee741c3508bdf8582.tar.gz iced-9edd805c0257cf360d7f9c0ee741c3508bdf8582.tar.bz2 iced-9edd805c0257cf360d7f9c0ee741c3508bdf8582.zip |
Add `mouse::Button` to `mouse::Click`
Diffstat (limited to 'core/src/mouse')
-rw-r--r-- | core/src/mouse/click.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/src/mouse/click.rs b/core/src/mouse/click.rs index 6f3844be..07a4db5a 100644 --- a/core/src/mouse/click.rs +++ b/core/src/mouse/click.rs @@ -1,4 +1,5 @@ //! Track mouse clicks. +use crate::mouse::Button; use crate::time::Instant; use crate::Point; @@ -6,6 +7,7 @@ use crate::Point; #[derive(Debug, Clone, Copy)] pub struct Click { kind: Kind, + button: Button, position: Point, time: Instant, } @@ -36,11 +38,17 @@ impl Kind { impl Click { /// Creates a new [`Click`] with the given position and previous last /// [`Click`]. - pub fn new(position: Point, previous: Option<Click>) -> Click { + pub fn new( + position: Point, + button: Button, + previous: Option<Click>, + ) -> Click { let time = Instant::now(); let kind = if let Some(previous) = previous { - if previous.is_consecutive(position, time) { + if previous.is_consecutive(position, time) + && button == previous.button + { previous.kind.next() } else { Kind::Single @@ -51,6 +59,7 @@ impl Click { Click { kind, + button, position, time, } |