/** * Generates a writable property that represents the selected value for this toggele group. * If the toggles are configured with a value (@see #togglebutton and #radiogroup) the corresponding * toggle will be selected when this value is changed. Likewise, if the toggle is changed by clicking * it, the value for the toggle will be written to this property. * To bind to this property, use the #ToggleGroup.bind() function. */ fun ToggleGroup.selectedValueProperty(): ObjectProperty = properties.getOrPut("tornadofx.selectedValueProperty") { SimpleObjectProperty().apply { selectedToggleProperty().onChange { value = it?.properties?.get("tornadofx.toggleGroupValue") as T? } onChange { selectedValue -> selectToggle(toggles.find { it.properties["tornadofx.toggleGroupValue"] == selectedValue }) } } } as ObjectProperty