Hey all! Wondering if there is an easy way to bind...
# tornadofx
s
Hey all! Wondering if there is an easy way to bind something with some kind of offset in place, like binding something to the stage's widthProperty but always subtracting a certain amount? Do I need to bind to a different property I make which is
= widthProperty() - customSubtractValue)
, or is there a way to do this without having to create a custom property (if this is even possible 😬)? This is what I'm trying to do, but obviously it will not work as I cannot subtract a
.px
val from an observable property.
Copy code
prefWidthProperty().bind(primaryStage.widthProperty() - sideBarWidth)
For more context, I'm trying to animate between two different views that lie within a larger container that contains a sidebar, and if I simply use
hGrow = Priority.ALWAYS
it causes animation stuttering as it "grows" while animating, so I need the width value of the new fragment to be a set amount before the animation begins. Thus, my binding dilemma. If there is a better way to do this, please share 😩
r
You can't really do this with
.px
values as JavaFX doesn't have a concept of units while running (it converts all CSS units to equivalent pixel values). If you're working with pixels though, you can just use the double value.