All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tornadofx.controlsfx.TextFields.kt Maven / Gradle / Ivy

There is a newer version: 0.1.1
Show newest version
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)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy