-1

I observed that in JavaFX textarea, Ctrl + z (for undo operation) is not working after calling textArea.setText("..."). Before setText is called, the undo operation is working fine.

Is there any way to enable undo accross multiple setText calls?

Lavish Kothari
  • 2,211
  • 21
  • 29

1 Answers1

0

Use replaceText instead of setText.

I looked at the code for TextArea (and TextInputControl) and found that replaceText takes care of saving previous "actions" whereas setText() will not save previous actions. So undo operation (using ctrl + z) works as expected when using replaceText.

Lavish Kothari
  • 2,211
  • 21
  • 29