0

I'm using RichTextFX to implement a commandline interface. What this means is that only the last line of text should be editable, while the previous content should be readonly.

Is there a way to mark a given span as readonly? If not, what is the best way to solve this problem?

Note that I eventually will want to allow other parts of the content to be editable, and not just the last line, so I'm really looking for a generic solution.

Elias Mårtenson
  • 3,820
  • 23
  • 32
  • 1
    I would recommend using two separated controls, one will act as the input field, and the second one as the log. I used RichTextFX in the past, I can't tell you if it is possible to achieve what you are asking for or no, but in case it's possible, you will have to update the non-editable range each time a command is entered. But using two separated controls, you will just append the entered commands to the non-editable one and clear the input field (in case of a CLI). – adxl Mar 17 '20 at 17:22
  • 1
    Interestingly, this is pretty straightforward in a plain JavaFX `TextArea`, using a `TextFormatter` with a `filter`. But I'm guessing you want to do something like syntax highlighting, so that's not particularly helpful. – James_D Mar 17 '20 at 17:50

0 Answers0