Skip to content

onHighlightPress property is not working on IOS OS 16+ #14

@react3-moon

Description

@react3-moon

onHighlightPress property is not working on IOS OS 16+

    "react": "17.0.2",
    "react-native": "0.67.2",
    "@alentoma/react-native-selectable-text": "1.6.0",

below mentioned code always return 0 for clickedRangeStart & clickedRangeEnd.

-(void) handleSingleTap: (UITapGestureRecognizer *) gesture
{
    CGPoint pos = [gesture locationInView:_backedTextInputView];
    pos.y += _backedTextInputView.contentOffset.y;
    
    UITextPosition *tapPos = [_backedTextInputView closestPositionToPoint:pos];
    UITextRange *word = [_backedTextInputView.tokenizer rangeEnclosingPosition:tapPos withGranularity:(UITextGranularityWord) inDirection:UITextLayoutDirectionRight];
    
    UITextPosition* beginning = _backedTextInputView.beginningOfDocument;
    
    UITextPosition *selectionStart = word.start;
    UITextPosition *selectionEnd = word.end;
    
    const NSInteger location = [_backedTextInputView offsetFromPosition:beginning toPosition:selectionStart];
    const NSInteger endLocation = [_backedTextInputView offsetFromPosition:beginning toPosition:selectionEnd];
    
    self.onHighlightPress(@{
        @"clickedRangeStart": @(location),
        @"clickedRangeEnd": @(endLocation),
    });
}

@AlenToma

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions