From 0550cac71b3dbce87ec161df1e3273e42e696854 Mon Sep 17 00:00:00 2001 From: Edvin Syse Date: Fri, 22 Mar 2019 10:14:21 +0100 Subject: [PATCH] `togglegroup()` builder accepts property parameter (/~https://github.com/edvin/tornadofx/issues/956) --- CHANGELOG.md | 1 + src/main/java/tornadofx/Controls.kt | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5969d8ec0..f1e53bed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Added `cubiccurveTo` builder (/~https://github.com/edvin/tornadofx/issues/911) - onLeftClick() and onRightClick() - Convenience function builders for SimpleXXXProperty classes (/~https://github.com/edvin/tornadofx/pull/935) +- `togglegroup()` builder accepts property parameter (/~https://github.com/edvin/tornadofx/issues/956) ## [1.7.18] diff --git a/src/main/java/tornadofx/Controls.kt b/src/main/java/tornadofx/Controls.kt index 648adde64..213222d52 100644 --- a/src/main/java/tornadofx/Controls.kt +++ b/src/main/java/tornadofx/Controls.kt @@ -237,9 +237,10 @@ fun ButtonBar.button(text: ObservableValue, type: ButtonBar.ButtonData? op(it) } -fun Node.togglegroup(op: ToggleGroup.() -> Unit = {}) = ToggleGroup().also { - properties["tornadofx.togglegroup"] = it - op(it) +fun Node.togglegroup(property: ObservableValue? = null, op: ToggleGroup.() -> Unit = {}) = ToggleGroup().also {tg -> + properties["tornadofx.togglegroup"] = tg + property?.let { tg.bind(it) } + op(tg) } /**