FXMisc / RichTextFX

Rich-text area for JavaFX
BSD 2-Clause "Simplified" License
1.21k stars 237 forks source link

Inserting caret offset by css padding #285

Closed terjedahl closed 7 years ago

terjedahl commented 8 years ago

When applying style to StyledTextArea such as: "-fx-padding: 10;", and then clicking in the text to insert the caret, the caret gets inserted 10px to the right of where I clicked - in practice more than one character later than where I tried to insert it.

JordanMartinez commented 8 years ago

I wasn't able to reproduce this issue via the example below

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.fxmisc.richtext.CharacterHit;
import org.fxmisc.richtext.InlineCssTextArea;

public class Moko extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        InlineCssTextArea area = new InlineCssTextArea("One.\nTwo.\nThree.");
        area.setStyle("-fx-padding: 20;");
        Scene scene = new Scene(new StackPane(area), 500, 500);

        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
TomasMikula commented 7 years ago

Fixed by #396