diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-16 14:26:12 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-16 14:26:12 +0800 |
| commit | 9feb6a1611a86b90a02b5bfe2b1d4c8189650491 (patch) | |
| tree | 96a66d98a6354f11432246405d0dfaf421d5f08f /src/platform/graphics/quartz/TextLayout.cpp | |
| parent | 07d662aafc25b145eb20e4123ebc82b5736cdeb7 (diff) | |
| download | cru-9feb6a1611a86b90a02b5bfe2b1d4c8189650491.tar.gz cru-9feb6a1611a86b90a02b5bfe2b1d4c8189650491.tar.bz2 cru-9feb6a1611a86b90a02b5bfe2b1d4c8189650491.zip | |
Fix text edit hittest trailing bug.
Diffstat (limited to 'src/platform/graphics/quartz/TextLayout.cpp')
| -rw-r--r-- | src/platform/graphics/quartz/TextLayout.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/platform/graphics/quartz/TextLayout.cpp b/src/platform/graphics/quartz/TextLayout.cpp index f98cff3a..4793a19c 100644 --- a/src/platform/graphics/quartz/TextLayout.cpp +++ b/src/platform/graphics/quartz/TextLayout.cpp @@ -180,11 +180,11 @@ Rect OsxCTTextLayout::TextSinglePoint(Index position, bool trailing) { TextHitTestResult OsxCTTextLayout::HitTest(const Point& point) { if (point.y < head_empty_line_count_ * font_->GetFontSize()) { if (point.y < 0) { - return {0, false, false}; + return {0, false, false, 0}; } else { for (int i = 1; i <= head_empty_line_count_; ++i) { if (point.y < i * font_->GetFontSize()) { - return {i - 1, false, false}; + return {i - 1, false, false, i - 1}; } } } @@ -197,11 +197,14 @@ TextHitTestResult OsxCTTextLayout::HitTest(const Point& point) { if (point.y >= th) { for (int i = 1; i <= tail_empty_line_count_; ++i) { if (point.y < th + i * font_->GetFontSize()) { - return {static_cast<Index>(text_.size() - (tail_empty_line_count_ - i)), - false, false}; + return { + static_cast<Index>(text_.size() - (tail_empty_line_count_ - i)), + false, false, + static_cast<Index>(text_.size() - (tail_empty_line_count_ - i))}; } } - return {static_cast<Index>(text_.size()), false, false}; + return {static_cast<Index>(text_.size()), false, false, + static_cast<Index>(text_.size())}; } auto p = point; @@ -261,11 +264,12 @@ TextHitTestResult OsxCTTextLayout::HitTest(const Point& point) { --po; } - return {po + head_empty_line_count_, false, inside_text}; + return {po + head_empty_line_count_, false, inside_text, + po + head_empty_line_count_}; } } - return TextHitTestResult{0, false, false}; + return TextHitTestResult{0, false, false, 0}; } void OsxCTTextLayout::ReleaseResource() { |
