summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2021-08-26 14:53:15 +0700
committerLibravatar GitHub <noreply@github.com>2021-08-26 14:53:15 +0700
commit6821114cae2e41fd2bc69d6fcaee1e8574ac061d (patch)
tree5741859eba63251190eb0a901a72ef4e185349e7 /graphics/src/widget
parent2d65621a3b680457e689b93c800e74f726ffc175 (diff)
parent7614127d3641cf3224798c2f0ff07b6ae57d9a53 (diff)
downloadiced-6821114cae2e41fd2bc69d6fcaee1e8574ac061d.tar.gz
iced-6821114cae2e41fd2bc69d6fcaee1e8574ac061d.tar.bz2
iced-6821114cae2e41fd2bc69d6fcaee1e8574ac061d.zip
Merge pull request #670 from twitchyliquid64/text_backend
Refactor textual hit testing into a `renderer::Backend` method
Diffstat (limited to 'graphics/src/widget')
-rw-r--r--graphics/src/widget/text.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/graphics/src/widget/text.rs b/graphics/src/widget/text.rs
index 7e22e680..c235f254 100644
--- a/graphics/src/widget/text.rs
+++ b/graphics/src/widget/text.rs
@@ -4,7 +4,7 @@ use crate::{Primitive, Renderer};
use iced_native::mouse;
use iced_native::text;
use iced_native::{
- Color, Font, HorizontalAlignment, Rectangle, Size, VerticalAlignment,
+ Color, Font, HorizontalAlignment, Point, Rectangle, Size, VerticalAlignment,
};
/// A paragraph of text.
@@ -35,6 +35,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,
+ ) -> text::Hit {
+ self.backend().hit_test(
+ content,
+ size,
+ font,
+ bounds,
+ point,
+ nearest_only,
+ )
+ }
+
fn draw(
&mut self,
defaults: &Self::Defaults,