You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently I am aware that we need to use requestFollowCaret() to scroll to caret.
However, I am not finding a solution for displaying the selected text (entirely if fits in viewport, otherwise partially).
For most cases it is working fine. However, sometimes, the selected text is just to the left of the viewport and scrolling a bit to the left reveals the highlighted text.
Is there some way I can make sure that the selected text gets displayed inside the viewport?
Here is a sample code of what I am doing right now:
BTW your codeArea.moveTo(start); .... attempt can work but it requires a scene graph pulse to occur between it and codeArea.selectRange(start, end); .... So like a 20ms delay needs to happen between the two, which is a pain.
An alternative which I haven't tried is to change the anchor position of the selection when needed. So if the next selection is to the left of the last selection [use getParagraphSelection( parIdx ) to get the selection start & end relative to the paragraph] then select the word/phrase backwards so that the caret is at the start of the selection.
The above are just suggestions if you can't use the PR or wait until the next release.
// select the text
codeArea.selectRange(start, end);
// scroll to selection
codeArea.scrollXToPixel(0);
codeArea.requestFollowCaret();
This works perfectly, by first scrolling to the very left, and then scrolling to the caret, making it always display the selection inside the viewport.
Currently I am aware that we need to use
requestFollowCaret()
to scroll to caret.However, I am not finding a solution for displaying the selected text (entirely if fits in viewport, otherwise partially).
For most cases it is working fine. However, sometimes, the selected text is just to the left of the viewport and scrolling a bit to the left reveals the highlighted text.
Is there some way I can make sure that the selected text gets displayed inside the viewport?
Here is a sample code of what I am doing right now:
I tried doing the following, but to no avail:
The use of these selections, for me, is for a find (and replace) option as found in most text editors.
The text was updated successfully, but these errors were encountered: