From 9fcfb4e601449e8aab0da4b0b4a978bc9b218607 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 15 Oct 2017 14:54:07 +0200 Subject: [PATCH] moved ParagraphText specific code from createStyledTextNode() methods to class ParagraphText --- .../richtext/demo/hyperlink/TextHyperlinkArea.java | 4 ---- .../java/org/fxmisc/richtext/ParagraphText.java | 14 +++++++++++--- .../java/org/fxmisc/richtext/StyledTextArea.java | 4 ---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/hyperlink/TextHyperlinkArea.java b/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/hyperlink/TextHyperlinkArea.java index b763ce249..f5881c6af 100644 --- a/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/hyperlink/TextHyperlinkArea.java +++ b/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/hyperlink/TextHyperlinkArea.java @@ -62,10 +62,6 @@ public static TextExt createStyledTextNode(Consumer applySegment) { TextExt t = new TextExt(); t.setTextOrigin(VPos.TOP); applySegment.accept(t); - - // XXX: binding selectionFill to textFill, - // see the note at highlightTextFill - t.impl_selectionFillProperty().bind(t.fillProperty()); return t; } } diff --git a/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java b/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java index 91c70e033..9502a8376 100644 --- a/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java +++ b/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java @@ -112,7 +112,15 @@ public ObjectProperty highlightTextFillProperty() { // }); // populate with text nodes - par.getStyledSegments().stream().map(nodeFactory).forEach(getChildren()::add); + par.getStyledSegments().stream().map(nodeFactory).forEach(n -> { + if (n instanceof TextExt) { + TextExt t = (TextExt) n; + // XXX: binding selectionFill to textFill, + // see the note at highlightTextFill + t.impl_selectionFillProperty().bind(t.fillProperty()); + } + getChildren().add(n); + }); // set up custom css shape helpers Supplier createBackgroundShape = () -> { @@ -406,8 +414,8 @@ private void updateSharedShapeRange(T value, int start, int end) { T lastShapeValue = lastShapeValueRange._1; // calculate smallest possible position which is consecutive to the given start position - final int prevEndNext = lastShapeValueRange.get2().getEnd() + 1; - if (start <= prevEndNext && // Consecutive? + final int prevEndNext = lastShapeValueRange.get2().getEnd() + 1; + if (start <= prevEndNext && // Consecutive? lastShapeValue.equals(value)) { // Same style? IndexRange lastRange = lastShapeValueRange._2; diff --git a/richtextfx/src/main/java/org/fxmisc/richtext/StyledTextArea.java b/richtextfx/src/main/java/org/fxmisc/richtext/StyledTextArea.java index 015a809cc..84024ea4e 100644 --- a/richtextfx/src/main/java/org/fxmisc/richtext/StyledTextArea.java +++ b/richtextfx/src/main/java/org/fxmisc/richtext/StyledTextArea.java @@ -130,10 +130,6 @@ public static Node createStyledTextNode(String text, S style, t.setTextOrigin(VPos.TOP); t.getStyleClass().add("text"); applyStyle.accept(t, style); - - // XXX: binding selectionFill to textFill, - // see the note at highlightTextFill - t.impl_selectionFillProperty().bind(t.fillProperty()); return t; } }