Skip to content

Commit

Permalink
Add CSS class to text and fix selection end calculation.
Browse files Browse the repository at this point in the history
The "text" CSS class is now added for styling purposes. Additionally, corrected the text selection end calculation to prevent off-by-one errors during selection.
  • Loading branch information
dlemmermann committed Aug 20, 2024
1 parent 42c795e commit 03a46ef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gemsfx/src/main/java/com/dlsc/gemsfx/skins/TextViewSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public SelectableText(TextView textView) {
setCursor(Cursor.TEXT);
setPrefWidth(Region.USE_PREF_SIZE);

text.getStyleClass().add("text");
text.textProperty().bind(textView.textProperty());
text.selectionFillProperty().bind(textView.highlightTextFillProperty());

Expand Down Expand Up @@ -231,7 +232,7 @@ private void selectParagraph(HitInfo hit) {

private void performSelection() {
text.setSelectionStart(selectionStartPos);
text.setSelectionEnd(Math.min(selectionEndPos, getTextFlowContentAsString().length() + 1));
text.setSelectionEnd(Math.min(selectionEndPos, getTextFlowContentAsString().length()));

PathElement[] selectionRange = rangeShape(selectionStartPos, selectionEndPos);
wrappingPath.getElements().setAll(selectionRange);
Expand Down

0 comments on commit 03a46ef

Please sign in to comment.