Implement textual hit testing

This commit is contained in:
Tom 2021-08-21 10:31:26 -07:00
parent 8333b8f88c
commit aa63841e2c
13 changed files with 341 additions and 75 deletions

View file

@ -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,