-
Notifications
You must be signed in to change notification settings - Fork 236
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
CodeArea in Dialog wrong caret position calculation #196
Comments
Hi, thanks for reporting. Can you provide a self-contained (a single Thanks, |
import javafx.application.Application;
import javafx.scene.control.*;
import javafx.stage.Stage;
import org.fxmisc.richtext.CodeArea;
public class Test extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Dialog<Boolean> dialog = new Dialog<>();
CodeArea codeArea = new CodeArea("Text\nText\nText");
dialog.getDialogPane().setContent(codeArea);
dialog.getDialogPane().getButtonTypes().add(ButtonType.OK);
dialog.showAndWait();
}
} Try to position cursor by mouse to first line. Align mouse cursor to center of first line and click - cursor places on second line. In non dialog mode it works ok. |
Thank you, I can reproduce the problem. So it seems that dialog adds some padding to its content node and A workaround is to wrap dialog.getDialogPane().setContent(new StackPane(codeArea)); |
Thank you for workaround. |
Or if you really have to hack it, then you might go to StyledTextAreaView and subtract the margin (5 pixes in the following example) there... not nice solution, but a working one. CharacterHit hit(double x, double y) {
double xMinusMargin = x - 5;
double yMinusMargin = y - 5;
VirtualFlowHit<Cell<Paragraph<S, PS>, ParagraphBox<S, PS>>> hit = virtualFlow.hit(xMinusMargin, yMinusMargin); |
Using Linux and this version of Java
I couldn't reproduce this problem with the above example. |
Now I can't reproduce it either, tried also with JDK 1.8.0_40. Not sure what version I tested this before, but dialogs were only added in 1.8.0_40 I believe... Weird. |
Problem still exists on windows platform, tested with jdk 1.8.0_65 |
ups, sorry, i use old richtextfx version, latest version from git work fine for me. |
in latest git version this issue fixed. |
Embed CodeArea to javafx javafx.scene.control.Dialog:
Then try to select portion of text - looks like cursor position a bit shifted from original one, so it is hard to point to exact symbol.
The text was updated successfully, but these errors were encountered: