Reputation: 43
I'm writing a text editor in JavaFX with the RichTextFX library and when I write a tab it has a width of 8. How can I change this without replacing the tab with e.g. 4 whitespaces?
This is what I have at the moment:
Nodes.addInputMap(this.codeArea, InputMap.consume(EventPattern.keyPressed(KeyCode.TAB), e -> {
this.codeArea.replaceSelection(" ");
}));
It replaces a tab with 4 whitespaces but how can I make that one tab is displayed with a width of 4 whitespaces?
Thank you for answering!
Upvotes: 0
Views: 271
Reputation: 4371
This depends on what version of JavaFX you are using. This https://bugs.openjdk.java.net/browse/JDK-8130738 was implemented in JavaFX 14.
See: https://openjfx.io/javadoc/14/javafx.graphics/javafx/scene/text/TextFlow.html#tabSizeProperty
and: https://openjfx.io/javadoc/14/javafx.graphics/javafx/scene/doc-files/cssref.html#text
Upvotes: 2