From af7ef50a6e59c08eb2b05c37176bcb3b67360056 Mon Sep 17 00:00:00 2001 From: zhimingao Date: Mon, 10 Apr 2023 14:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90Bugfix=E3=80=91=E6=89=A9=E5=A4=A7?= =?UTF-8?q?=E7=83=AD=E5=8C=BA=EF=BC=8C=E4=BF=9D=E8=AF=81=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E6=9C=89=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/MPILabel.m | 5 +++++ Sources/MPITextSelectionView.m | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/MPILabel.m b/Sources/MPILabel.m index f7e9304..e51c628 100644 --- a/Sources/MPILabel.m +++ b/Sources/MPILabel.m @@ -740,6 +740,11 @@ - (CGRect)grabberRectForGrabberType:(MPITextSelectionGrabberType)grabberType { - (NSUInteger)characterIndexForPoint:(CGPoint)point { MPITextRenderer *renderer = [self currentRenderer]; point = [self convertPointToTextKit:point forBounds:self.bounds textSize:renderer.size]; + CGFloat pointX = MIN(point.x, renderer.size.width) - 1; + CGFloat pointY = MIN(point.y, renderer.size.height) - 1; + pointX = pointX < 0 ? 1 : pointX; + pointY = pointY < 0 ? 1 : pointY; + point = CGPointMake(pointX, pointY); return [renderer characterIndexForPoint:point]; } diff --git a/Sources/MPITextSelectionView.m b/Sources/MPITextSelectionView.m index ae644dd..e3d6a16 100644 --- a/Sources/MPITextSelectionView.m +++ b/Sources/MPITextSelectionView.m @@ -8,7 +8,7 @@ #import "MPITextSelectionView.h" #import "MPITextGeometryHelpers.h" -#define kGrabberTouchHitTestExtend 14.0 +#define kGrabberTouchHitTestExtend 20.0 #define kKnobTouchHitTestExtend 7.0 #define kSelectionAlpha 0.2