Closed byteab closed 1 month ago
Hey @ehxxn
You can use https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-focused-input-handler#onselectionchange to get x
/y
coordinates
If you want to extend TextInput
then you can capture its tag and compare with the tag from event:
const CustomTextInput = (props) => {
const ref = useRef();
const [tag, setTag] = useState(-1);
useEffect(() => {
setTag(findNodeHandle(ref));
}, []);
useFocusedInputHandler({
onSelectionChange: (e) => {
"worklet";
if (e.target === tag) {
runOnJS(props.customPropHandler)(e);
}
}
}, [tag]);
return <TextInput ref={ref} {...props} />
}
You may check example app to see how it works in action 👀
Thank you very much! I'll try those solutions
@ehxxn if you discover, that something is not working or find any bugs - feel free to open new issue in keyboard-controller repository 🙌
Yes, it should be possible to extend the native code so that
onSelectionChange
event returnsselection.cursorPosition.x
and.y
as well (on iOS) and its counterpart on Android.