diff options
author | 2021-08-21 10:31:26 -0700 | |
---|---|---|
committer | 2021-08-21 10:31:26 -0700 | |
commit | aa63841e2c80ca8130adf41d25e5d731409b92f4 (patch) | |
tree | 4dab3f0405dc002a06f0e36ec40f2f74ff07212b /wgpu/src/backend.rs | |
parent | 8333b8f88ceaa53c361eb6726b2b7dac6cd2c402 (diff) | |
download | iced-aa63841e2c80ca8130adf41d25e5d731409b92f4.tar.gz iced-aa63841e2c80ca8130adf41d25e5d731409b92f4.tar.bz2 iced-aa63841e2c80ca8130adf41d25e5d731409b92f4.zip |
Implement textual hit testing
Diffstat (limited to 'wgpu/src/backend.rs')
-rw-r--r-- | wgpu/src/backend.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 4f34045b..fe8ed255 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -7,7 +7,9 @@ use iced_graphics::font; use iced_graphics::layer::Layer; use iced_graphics::{Primitive, Viewport}; use iced_native::mouse; -use iced_native::{Font, HorizontalAlignment, Size, VerticalAlignment}; +use iced_native::{ + Font, HitTestResult, HorizontalAlignment, Size, VerticalAlignment, +}; #[cfg(any(feature = "image_rs", feature = "svg"))] use crate::image; @@ -274,6 +276,25 @@ impl backend::Text for Backend { ) -> (f32, f32) { self.text_pipeline.measure(contents, size, font, bounds) } + + fn hit_test( + &self, + contents: &str, + size: f32, + font: Font, + bounds: Size, + point: iced_native::Point, + nearest_only: bool, + ) -> HitTestResult { + self.text_pipeline.hit_test( + contents, + size, + font, + bounds, + point, + nearest_only, + ) + } } #[cfg(feature = "image_rs")] |