This repository has been archived by the owner on Sep 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 271
ObservableStyleClass #88
Comments
Stylesheet: .success { -fx-background-color: green }
.danger { -fx-background-color: red }
.warning { -fx-background-color: orange } Demo app: class StyleClassView : View() {
override val root = HBox()
init {
importStylesheet(TestStylesheet::class)
with(root) {
padding = Insets(70.0)
// The observable property
val selectedClass = SimpleStringProperty()
// A combo box that updates the observable property
combobox(selectedClass, listOf("success", "danger", "warning").observable())
// Bind the current value as a styleClass on the HBox
bindClass(selectedClass)
}
}
}
|
@t-boom I put this functionality in |
Completed, will be in the |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Some times you want to swap a style class on a node depending on some other state. It would be convenient to ble able to bind a
Property<String>
to aNode
and have the value of the property reflected in thestyleClass
list of that node.When the property changes, the old value would be removed from the style class and the new value would be added.
The text was updated successfully, but these errors were encountered: