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

Commit

Permalink
ButtonBar.button builder (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvin Syse committed Apr 26, 2016
1 parent d6bf9dd commit e0bf934
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/tornadofx/Builders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e0bf934

Please sign in to comment.