Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Bind ToggleGroup selected property to external property in the DSL builder #956

Closed
aleksandar-stefanovic opened this issue Mar 22, 2019 · 2 comments

Comments

@aleksandar-stefanovic
Copy link
Contributor

aleksandar-stefanovic commented Mar 22, 2019

Considering this scenario:

    val selectedOrientationProperty = SimpleObjectProperty<Orientation>()

    togglegroup {
        radiobutton("Vertical", value = Orientation.VERTICAL)
        radiobutton("Horizontal", value = Orientaion.HORIZONTAL)
    }

There's no simple way to bind the selectedOrientationProperty to the selection of the togglegroup. I think something like this should exist:

    val selectedOrientationProperty = SimpleObjectProperty<Orientation>()

    togglegroup(selectedOrientationProperty) {
        radiobutton("Vertical", value = Orientation.VERTICAL)
        radiobutton("Horizontal", value = Orientaion.HORIZONTAL)
    }

Which would be a shorthand for something like:

    val selectedOrientationProperty = SimpleObjectProperty<Orientation>()

    togglegroup {
        selectedOrientationProperty.bind(selectedValueProperty())
        radiobutton("Vertical", value = Orientation.VERTICAL)
        radiobutton("Horizontal", value = Orientaion.HORIZONTAL)
    }

If this issue is confirmed, I could try and make it happen.

@edvin
Copy link
Owner

edvin commented Mar 22, 2019

I'd say bind(selectedOrientationProperty) is simple enough :)

But you're right, there is no reason not to include a builder parameter for the property, so I've commited this addition now. You can now do:

togglegroup(selectedOrientationProperty) {
}

@aleksandar-stefanovic
Copy link
Contributor Author

Excellent, thanks!

I think that it is more about consistency, because other controls have the option to bind the property in their builders.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants