Created
October 9, 2017 21:13
-
-
Save Palisand/e91fb7bed4facd9af0df6b68b33d25f6 to your computer and use it in GitHub Desktop.
Changes for scroll-to-cursor functionality.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (RCTTextSelection *)selection | |
{ | |
id<RCTBackedTextInputViewProtocol> backedTextInput = self.backedTextInputView; | |
UITextRange *selectedTextRange = backedTextInput.selectedTextRange; | |
return [[RCTTextSelection new] initWithStart:[backedTextInput offsetFromPosition:backedTextInput.beginningOfDocument toPosition:selectedTextRange.start] | |
end:[backedTextInput offsetFromPosition:backedTextInput.beginningOfDocument toPosition:selectedTextRange.end] | |
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ | |
cursorPosition:[backedTextInput caretRectForPosition:selectedTextRange.start].origin]; | |
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ | |
} | |
... | |
- (void)textInputDidChangeSelection | |
{ | |
if (!_onSelectionChange) { | |
return; | |
} | |
RCTTextSelection *selection = self.selection; | |
_onSelectionChange(@{ | |
@"selection": @{ | |
@"start": @(selection.start), | |
@"end": @(selection.end), | |
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ | |
@"cursorPositionX": @(selection.cursorPosition.x), | |
@"cursorPositionY": @(selection.cursorPosition.y) | |
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ | |
}, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment