diff --git a/CHANGELOG.md b/CHANGELOG.md index c85d040f2..cab52d24c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - `children(nodeList)` builder helper to redirect built children to a specific node list (/~https://github.com/edvin/tornadofx/issues/95) - `buttonbar` builder (/~https://github.com/edvin/tornadofx/issues/95) +- `ButtonBar.button` builder (/~https://github.com/edvin/tornadofx/issues/95) - `togglegroup` builder ## [1.4.3] - 2016-04-23 diff --git a/src/main/java/tornadofx/Builders.kt b/src/main/java/tornadofx/Builders.kt index bfbc62549..b61055e29 100644 --- a/src/main/java/tornadofx/Builders.kt +++ b/src/main/java/tornadofx/Builders.kt @@ -148,6 +148,7 @@ fun Pane.slider(min: Double? = null, max: Double? = null, value: Double? = null, if (orientation != null) this.orientation = orientation }, op) + fun Pane.button(text: String = "", graphic: Node? = null, op: (Button.() -> Unit)? = null): Button { val button = Button(text) if (graphic != null) button.graphic = graphic @@ -163,6 +164,15 @@ fun ToolBar.button(text: String = "", graphic: Node? = null, op: (Button.() -> U return button } +fun ButtonBar.button(text: String = "", graphic: Node? = null, op: (Button.() -> Unit)? = null): Button { + val button = Button(text) + if (graphic != null) + button.graphic = graphic + buttons.add(button) + op?.invoke(button) + return button +} + fun Pane.togglegroup(op: (ToggleGroup.() -> Unit)? = null): ToggleGroup { val group = ToggleGroup() properties["tornadofx.togglegroup"] = group