For multi-line paragraphs you often want to move the view to a specific line, for example when doing a search to show a match or moving to a line or for a specific text offset.
What is the best way to do this?
NavigationActions.moveTo moves the caret but not the view, and that isn't really desirable anyway in the general case.
The scroll[]ToPixel methods are possible but how would I translate a text offset into a view pixel offset? Also, in general how do I determine the view offset of a text offset that is currently not on screen?
You can use area.showParagraphAtTop(int paragraphIndex) or its bottom counterpart, or area.showParagraphInViewport(int paragraphIndex) to insure the paragraph is visible. There are two other methods not yet exposed from Flowless: VirtualFlow#show(int cellIndex, double yOffset) and VirtualFlow#show(int cellIndex, Bounds regionInCell)
As for ones that show a line specifically, you'd need to use a mixture of the above. Since the VirtualFlow only renders the paragraphs that are visible as a way to save memory and increase speed, you would need to show that paragraph first, calculate where on the screen the thing in the paragraph you want to show is, calculate an offset value using that, and then scroll by that offset value so that the line is visible or the part in the line is visible.
Closing since I think this has been answered.
Most helpful comment
You can use
area.showParagraphAtTop(int paragraphIndex)or its bottom counterpart, orarea.showParagraphInViewport(int paragraphIndex)to insure the paragraph is visible. There are two other methods not yet exposed from Flowless:VirtualFlow#show(int cellIndex, double yOffset)andVirtualFlow#show(int cellIndex, Bounds regionInCell)As for ones that show a line specifically, you'd need to use a mixture of the above. Since the VirtualFlow only renders the paragraphs that are visible as a way to save memory and increase speed, you would need to show that paragraph first, calculate where on the screen the thing in the paragraph you want to show is, calculate an offset value using that, and then scroll by that offset value so that the line is visible or the part in the line is visible.