Skip to content

Commit 567e7e8

Browse files
authored
Merge pull request #793 from JFormDesigner/background-offset-fix
Fix position of background, border and underline shapes in cases where the selection contains custom objects
2 parents 7be6dc4 + 493c024 commit 567e7e8

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import javafx.collections.ObservableMap;
2424
import javafx.collections.ObservableSet;
2525
import javafx.collections.SetChangeListener;
26-
import javafx.collections.transformation.FilteredList;
2726
import javafx.geometry.Bounds;
2827
import javafx.geometry.Insets;
2928
import javafx.scene.Node;
@@ -404,8 +403,15 @@ private void updateBackgroundShapes() {
404403
int start = 0;
405404

406405
// calculate shared values among consecutive nodes
407-
FilteredList<Node> nodeList = getChildren().filtered(node -> node instanceof TextExt);
408-
for (Node node : nodeList) {
406+
for (Node node : getManagedChildren()) {
407+
if (!(node instanceof TextExt)) {
408+
// node is a custom objects (e.g. image)
409+
// - custom objects do not support background color, border and underline
410+
// - text length of custom objects is always 1
411+
start += 1;
412+
continue;
413+
}
414+
409415
TextExt text = (TextExt) node;
410416
int end = start + text.getText().length();
411417

0 commit comments

Comments
 (0)