-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Listening to the area.selectedTextProperty and then selecting the text beyond the end leads to exception #991
Comments
Hi Gary, thanks for the bug report, minimal example, and stacktrace. I get a similar error by just clicking inside the padded area of the last line. Currently I think that the issue arises in Flowless, specifically I believe VirtualFlowHit<Cell<Paragraph<PS,SEG,S>, ParagraphBox<PS,SEG,S>>> hit = virtualFlow.hit(adjustedX, adjustedY);
if(hit.isBeforeCells()) {
return CharacterHit.insertionAt(0);
} else if(hit.isAfterCells()) { // is FALSE but should be TRUE ? Strangely this exception doesn't happen with JDK 1.8, only 1.9 and up ? |
Yes I found it was only the last line and if it had padding. It might be the JDK version or more likely it could be the JavaFX version. I'm using JavaFX version 12 on JDK 12 at the moment because the text rendering is a little wonky on JavaFX 12+ versions, so it could be that. Doesn't the hit call eventually call TextFlow.hitTest? Maybe the issue lies there. I was thinking about trying to get rid of the padding to prevent the issue happening but I'm having trouble styling the ParagraphBox instance, it's not taking notice of any padding I set in the stylesheet. I haven't exactly nailed down whether I'm at fault there though so I haven't reported it. |
Okay so after going down the rabbit hole I've found the problem and submitted a PR. You were close with the Which was the reason it only happens in JDK 9+ because this is the Java 9+ version that had some missing code from the original JDK 8 code. |
Thanks, that PR seems to fix the issue. |
This was tested using version 0.10.5.
For the following test code (the actual area instance used doesn't matter, this one was just convenient):
The test.css file contains:
The size of the padding isn't important, it's just there to let the issue happen.
If you then click in the area and then drag towards the end of the line and/or below the line you get the following exception:
The important things here are that the selectedTextProperty has a listener, there is padding around the paragraph-text and you try and select outside of the available text.
The text was updated successfully, but these errors were encountered: