summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-29 16:47:30 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-29 16:47:30 +0700
commit0b66095f9ffddad0a6bc6f4e8aa4e2311e89292a (patch)
tree0c34bb12c98f90ae4adad82227ca0adbfd231164 /graphics
parentde728737fd69265f812f717ca70d3e0bd40838e5 (diff)
downloadiced-0b66095f9ffddad0a6bc6f4e8aa4e2311e89292a.tar.gz
iced-0b66095f9ffddad0a6bc6f4e8aa4e2311e89292a.tar.bz2
iced-0b66095f9ffddad0a6bc6f4e8aa4e2311e89292a.zip
Implement `Widget::mouse_interaction` for `Canvas` in `iced_graphics`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/widget/canvas.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/graphics/src/widget/canvas.rs b/graphics/src/widget/canvas.rs
index 1b0d49d8..ad9704d0 100644
--- a/graphics/src/widget/canvas.rs
+++ b/graphics/src/widget/canvas.rs
@@ -7,6 +7,7 @@ use crate::renderer::{self, Renderer};
use crate::{Backend, Primitive};
use iced_native::layout;
+use iced_native::mouse;
use iced_native::{
Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Size, Vector,
Widget,
@@ -187,6 +188,18 @@ where
event::Status::Ignored
}
+ fn mouse_interaction(
+ &self,
+ layout: Layout<'_>,
+ _viewport: &Rectangle,
+ cursor_position: Point,
+ ) -> mouse::Interaction {
+ let bounds = layout.bounds();
+ let cursor = Cursor::from_window_position(cursor_position);
+
+ self.program.mouse_interaction(bounds, cursor)
+ }
+
fn draw(
&self,
renderer: &mut Renderer<B>,