Skip to content

Commit b6b4fb6

Browse files
Merge pull request #617 from JFormDesigner/createStyledTextNode-cleanup
moved ParagraphText specific code from createStyledTextNode() methods to class ParagraphText
2 parents 2f497bb + 9fcfb4e commit b6b4fb6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/hyperlink/TextHyperlinkArea.java

-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ public static TextExt createStyledTextNode(Consumer<TextExt> applySegment) {
6262
TextExt t = new TextExt();
6363
t.setTextOrigin(VPos.TOP);
6464
applySegment.accept(t);
65-
66-
// XXX: binding selectionFill to textFill,
67-
// see the note at highlightTextFill
68-
t.impl_selectionFillProperty().bind(t.fillProperty());
6965
return t;
7066
}
7167
}

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,15 @@ public ObjectProperty<Paint> highlightTextFillProperty() {
112112
// });
113113

114114
// populate with text nodes
115-
par.getStyledSegments().stream().map(nodeFactory).forEach(getChildren()::add);
115+
par.getStyledSegments().stream().map(nodeFactory).forEach(n -> {
116+
if (n instanceof TextExt) {
117+
TextExt t = (TextExt) n;
118+
// XXX: binding selectionFill to textFill,
119+
// see the note at highlightTextFill
120+
t.impl_selectionFillProperty().bind(t.fillProperty());
121+
}
122+
getChildren().add(n);
123+
});
116124

117125
// set up custom css shape helpers
118126
Supplier<Path> createBackgroundShape = () -> {
@@ -406,8 +414,8 @@ private void updateSharedShapeRange(T value, int start, int end) {
406414
T lastShapeValue = lastShapeValueRange._1;
407415

408416
// calculate smallest possible position which is consecutive to the given start position
409-
final int prevEndNext = lastShapeValueRange.get2().getEnd() + 1;
410-
if (start <= prevEndNext && // Consecutive?
417+
final int prevEndNext = lastShapeValueRange.get2().getEnd() + 1;
418+
if (start <= prevEndNext && // Consecutive?
411419
lastShapeValue.equals(value)) { // Same style?
412420

413421
IndexRange lastRange = lastShapeValueRange._2;

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

-4
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ public static <S> Node createStyledTextNode(String text, S style,
130130
t.setTextOrigin(VPos.TOP);
131131
t.getStyleClass().add("text");
132132
applyStyle.accept(t, style);
133-
134-
// XXX: binding selectionFill to textFill,
135-
// see the note at highlightTextFill
136-
t.impl_selectionFillProperty().bind(t.fillProperty());
137133
return t;
138134
}
139135
}

0 commit comments

Comments
 (0)