0

I'm designing a cmd like console I want to force the caret to last line so that previous line wont be editable.

codeArea.currentParagraphProperty().addListener((obs, o, n) -> codeArea.moveTo(codeArea.getLength()));

I used the above statement to force caret to last character of CodeArea although it works when I try to reach previous line but fails to work when I press backspace as it moves caret to previous line by removing characters. I want the caret to be uneditable from current paragraph containing directory path till first line of code area

  • Here is my guess-> Firstly, I think you will need to use `TextFormatter`. Secondly, I think you will need to do something like only allow text to change after the last newline character if there are one or more newline characters. If there are zero newline characters, allow text to change. I don't know what that means code wise. – SedJ601 Apr 21 '21 at 15:33
  • Sir text formatter is not present in Richtextfx codearea so are there any other way like validating key pressed before text is edited on codearea – Bibek Bhusan Sahoo Apr 30 '21 at 08:06
  • Sorry, I totally overlooked that part. Is there some way you can use `StringProperty` to keep up with what is going to be displayed in the `RichTextFX` codearea? – SedJ601 Apr 30 '21 at 15:42

1 Answers1

0

Rather than using this.

codeArea.currentParagraphProperty().addListener((obs, o, n) -> codeArea.moveTo(codeArea.getLength()));

Use this code:

codeArea.currentParagraphProperty().addListener((obs, o, n) -> codeArea.getCaretSelectionBind().moveTo(codeArea.getText().length()));