From aa63841e2c80ca8130adf41d25e5d731409b92f4 Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 21 Aug 2021 10:31:26 -0700 Subject: Implement textual hit testing --- graphics/src/widget/text.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'graphics/src/widget') diff --git a/graphics/src/widget/text.rs b/graphics/src/widget/text.rs index 7e22e680..e1b4e4e8 100644 --- a/graphics/src/widget/text.rs +++ b/graphics/src/widget/text.rs @@ -4,7 +4,8 @@ use crate::{Primitive, Renderer}; use iced_native::mouse; use iced_native::text; use iced_native::{ - Color, Font, HorizontalAlignment, Rectangle, Size, VerticalAlignment, + Color, Font, HitTestResult, HorizontalAlignment, Point, Rectangle, Size, + VerticalAlignment, }; /// A paragraph of text. @@ -35,6 +36,25 @@ where .measure(content, f32::from(size), font, bounds) } + fn hit_test( + &self, + content: &str, + size: f32, + font: Font, + bounds: Size, + point: Point, + nearest_only: bool, + ) -> HitTestResult { + self.backend().hit_test( + content, + size, + font, + bounds, + point, + nearest_only, + ) + } + fn draw( &mut self, defaults: &Self::Defaults, -- cgit From 7614127d3641cf3224798c2f0ff07b6ae57d9a53 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 26 Aug 2021 14:41:33 +0700 Subject: Rename `HitTestResult` to `Hit` ... and also move it to a new `text` module in `iced_core` --- graphics/src/widget/text.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'graphics/src/widget') diff --git a/graphics/src/widget/text.rs b/graphics/src/widget/text.rs index e1b4e4e8..c235f254 100644 --- a/graphics/src/widget/text.rs +++ b/graphics/src/widget/text.rs @@ -4,8 +4,7 @@ use crate::{Primitive, Renderer}; use iced_native::mouse; use iced_native::text; use iced_native::{ - Color, Font, HitTestResult, HorizontalAlignment, Point, Rectangle, Size, - VerticalAlignment, + Color, Font, HorizontalAlignment, Point, Rectangle, Size, VerticalAlignment, }; /// A paragraph of text. @@ -44,7 +43,7 @@ where bounds: Size, point: Point, nearest_only: bool, - ) -> HitTestResult { + ) -> text::Hit { self.backend().hit_test( content, size, -- cgit