tornadofx.controlsfx.TextFields.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tornadofx-controlsfx Show documentation
Show all versions of tornadofx-controlsfx Show documentation
TornadoFX integration library for ControlsFX
package tornadofx.controlsfx
import impl.org.controlsfx.autocompletion.SuggestionProvider
import javafx.beans.property.Property
import javafx.event.EventTarget
import javafx.scene.Node
import javafx.scene.control.TextField
import javafx.util.StringConverter
import org.controlsfx.control.textfield.CustomPasswordField
import org.controlsfx.control.textfield.CustomTextField
import org.controlsfx.control.textfield.TextFields
import tornadofx.*
fun TextField.bindAutoCompletion(vararg suggestions: T) {
TextFields.bindAutoCompletion(this, *suggestions)
}
fun TextField.bindAutoCompletion(suggestions: List) {
TextFields.bindAutoCompletion(this, suggestions)
}
fun TextField.bindAutoCompletion(suggestionsProvider: () -> Collection) {
TextFields.bindAutoCompletion(this, { suggestionsProvider() })
}
fun TextField.bindAutoCompletion(suggestionsProvider: () -> Collection, converter: StringConverter) {
TextFields.bindAutoCompletion(this, { suggestionsProvider() }, converter)
}
fun TextField.bindAutoCompletion(suggestionProvider: SuggestionProvider) {
TextFields.bindAutoCompletion(this, suggestionProvider)
}
fun EventTarget.clearableTextfield(op: (TextField.() -> Unit)? = null): TextField =
opcr(this, TextFields.createClearableTextField(), op)
fun EventTarget.clearablePasswordTextfield(op: (TextField.() -> Unit)? = null): TextField =
opcr(this, TextFields.createClearablePasswordField(), op)
fun EventTarget.customTextfield(op: (CustomTextField.() -> Unit)? = null): CustomTextField {
val customTextField = CustomTextField()
return opcr(this, customTextField, op)
}
fun EventTarget.customPasswordTextfield(op: (CustomPasswordField.() -> Unit)? = null): CustomPasswordField {
val customPasswordField = CustomPasswordField().apply {
this.left = left
this.right = right
}
return opcr(this, customPasswordField, op)
}
fun EventTarget.customTextfield(left: Node? = null, right: Node? = null, op: (CustomTextField.() -> Unit)? = null): CustomTextField {
val customTextField = CustomTextField().apply {
this.left = left
this.right = right
}
return opcr(this, customTextField, op)
}
fun EventTarget.customPasswordTextfield(left: Node? = null, right: Node? = null, op: (CustomPasswordField.() -> Unit)? = null): CustomPasswordField {
val customPasswordField = CustomPasswordField().apply {
this.left = left
this.right = right
}
return opcr(this, customPasswordField, op)
}
fun EventTarget.customTextfield(left: Property? = null, right: Property? = null, op: (CustomTextField.() -> Unit)? = null): CustomTextField {
val customTextField = CustomTextField().apply {
if (left != null) this.leftProperty().bindBidirectional(left)
if (right != null) this.rightProperty().bindBidirectional(right)
}
return opcr(this, customTextField, op)
}
fun EventTarget.customPasswordTextfield(left: Property? = null, right: Property? = null, op: (CustomPasswordField.() -> Unit)? = null): CustomPasswordField {
val customPasswordField = CustomPasswordField().apply {
if (left != null) this.leftProperty().bindBidirectional(left)
if (right != null) this.rightProperty().bindBidirectional(right)
}
return opcr(this, customPasswordField, op)
}