From f0c1aec40ed0ab4e6d59422f7cf33c1e8451729b Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 26 Jul 2024 09:33:33 -0700 Subject: [PATCH] Fixing selecting before/after the text --- CHANGELOG.md | 2 ++ src/widgets/input.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea6d5a9..1e13656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `WindowAttributes::inner_size` is `None`. - Container's layout and drawing functions now properly round up/down the measurements to ensure accurate rendering. Fixes [#158][158]. +- `Input` selection handling when dragging below or above the text field is now + handled correctly. [158]: https://github.com/khonsulabs/cushy/issues/158 diff --git a/src/widgets/input.rs b/src/widgets/input.rs index c5dd46a..71a5887 100644 --- a/src/widgets/input.rs +++ b/src/widgets/input.rs @@ -833,7 +833,7 @@ where .round(); let mut location = location - padding; if location.y < 0 { - location.y = Px::ZERO; + return Cursor::default(); } if location.x < 0 { location.x = Px::ZERO; @@ -885,6 +885,9 @@ where let relative = relative + rect.size / 2; let line_height = cache.measured.line_height.get(); + if relative.y >= line_height { + continue; + } let xy = relative .x .get()