edvin / tornadofx

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

In Wizard, the "Next" button doesn't appear disabled even when incomplete #960

Closed aleksandar-stefanovic closed 5 years ago

aleksandar-stefanovic commented 5 years ago

When using the Wizard, and overriding the complete expression, the button is disarmed when the expression is false, but it doesn't appear as disabled. Screenshot from 2019-03-25 18 12 00

edvin commented 5 years ago

Can you post some code showing the issue?

aleksandar-stefanovic commented 5 years ago

I've created a minimal example:

import javafx.beans.property.SimpleBooleanProperty
import tornadofx.*

class MyWizard : Wizard() {

    init {
        add(WizardStep1::class)
        add(WizardStep2::class)
    }
}

class WizardStep1 : View("Step 1") {

    override val complete = SimpleBooleanProperty(false)

    override val root = vbox { }

}

class WizardStep2 : View("Step 2") {
    override val root = vbox {}
}

In this example, the "Next" Button appears as not disabled, even though pressing it does nothing. If you change the property to true, the button works as expected (it goes to the next step when pressed)

aleksandar-stefanovic commented 5 years ago

Upon further investigation, these are the culprits:

Wizard.kt, (line ~168):

 enableWhen(canGoNext.and(hasNext))

Seems good, but then,

open val canGoNext: BooleanExpression = hasNext

Doesn't explain the discrepancy between being disarmed and being disabled, though.

edvin commented 5 years ago

The issue is that the enableWhen expression should also account for currentPageComplete. I've committed a fix now :)

aleksandar-stefanovic commented 5 years ago

Thank you!

edvin commented 5 years ago

Thanks for reporting :))