Is there any way to get the Y position of the TextInput cursor in react native, if possible without any native (android/ios) hacks? I don't mean the start and end of the cursor selection state. What I am trying to achieve is, when the keyboard is open, I would like to display a modal based on the position of the cursor, just like mentioning in Facebook and Instagram. Or may be at which line the cursor is at? That way I may be able to calculate the position of the cursor.
Meaning, if the cursor is in the beginning of the TextInput (Top of the screen) I would like to display the modal below the cursor upto the keyboard. And if the cursor is in the middle or bottom of the TextInput (middle of the visible area between the Top of the screen and Keyboard), I would like to display the modal above the cursor.
Use case:
- Here, the cursor is at the top of the screen.
And since, there is space between the cursor position and keyboard, I would like to display a modal in between the cursor and keyboard.
- In this case, the cursor is in about middle, between the top of the screen and keyboard.
And since in this case, there is much space above the cursor to the top of the screen, I would like to display the modal above the cursor.
- A user can also change the cursor position, and start typing from the new cursor position. Therefore, I cannot just measure the height of the TextInput and rely on the height of the TextInput, which is why I need to know where the cursor Y position is.
from How to get the cursor position of a TextInput relative to it's parent or screen in React native




No comments:
Post a Comment