Reputation: 17091
How can I use the textFormatter property to capitalize words that are typed into a textfield?
override val root = vbox {
textfield(model.instrument) {
textFormatter = TextFormatter (change -> change.text.toUpperCase() )
}
}
Upvotes: 0
Views: 158
Reputation: 841
TornadoFX actually has a filter builder that incorporates a text formatter:
override val root = vbox {
textfield(model.instrument) {
filterInput { change ->
change.text = change.text.toUpperCase()
true
}
}
}
The builder needs a boolean to determine if the new input is valid or not so it can actually accept or reject input.
Upvotes: 2
Reputation: 17091
Pretty simple:
textFormatter = TextFormatter<String> { change ->
change.text = change.text.toUpperCase()
change
}
Upvotes: -1