edvin / tornadofx

Lightweight JavaFX Framework for Kotlin
Apache License 2.0
3.67k stars 270 forks source link

Alert extensions #68

Closed edvin closed 8 years ago

edvin commented 8 years ago

Provide convenience function for working with Alerts.

thomasnield commented 8 years ago

Are we talking about those Dialog factories that were implemented into JavaFX 8 well after its release?

edvin commented 8 years ago

That's right. Their API is quite OK already, but we could still streamline a little :)

thomasnield commented 8 years ago

I agree. I'll see I I can help with this and a few of the other issues.

edvin commented 8 years ago

Cool! I'm in Oslo from today until Sunday, but hopefully I'll be able to put in a few hours every night atleast.

edvin commented 8 years ago

Implemented and will be in TornadoFX 1.4.3.

alert(CONFIRMATION, "Confirm delete", "Do you want to delete ${customer.name}?") {
    if (it == ButtonType.OK)
        customerController.deleteCustomer(customer)
}

Multiple outcomes:

alert(CONFIRMATION, "Choose action", "What do you want to do?", APPLY, NEXT, CLOSE) {
    when (it) {
        APPLY -> applyIt()
        NEXT -> gotoNext()
        CLOSE -> closeWindow()
    }
}