JDK-8149134 : [Text,TextFlow] Selection fill fails in subsequent Text nodes in TextFlow
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8,9
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2016-02-05
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
When setting selection ranges on Text elements of a TextFlow, the selectionFill color (normally white) is only painted in the first Text node.

The Text nodes share a TextLayout internally, and the indices seem to get mapped wrong across the layout runs.

Comments
Attached a first attempt at a fix. It seems to work, but is based on observations rather than an understanding of the underlying runs structure.
10-03-2016

A Text node knows if it is a "span", i.e. part of a TextFlow. By looping over the Text siblings in the parent TextFlow, we can count the length of preceding text and use that as an offset for the selection start and end. There seems to be a single character offset between Text nodes, regardless of whether there are non-Text nodes there or not. I will continue to look for a more sturdy fix, possibly looking at the runs in the underlying TextLayout instead.
15-02-2016

Attached test case JDK8149134_8.java for JavaFX 8, i.e. without the new public API from JDK-8143158.
05-02-2016