Fork me on GitHub
#cljfx
<
2021-06-22
>
thom20:06:41

How might one manage dynamic resizing of controls with cljfx? I see various JavaFX examples using bind which I don't think is exposed, but are width/height properties magically wrapped in event handlers somehow? I would happily use a border pane or similar, but ideally I'd be able to spot changes in a parent container's dimensions and use those to scale JavaFX shapes, which aren't resizeable like other controls.

vlaaad20:06:32

hmm, it looks like you will need to create an extra-props lifecycle (`make-ext-with-props`) that will add on-width-changed/on-height-changed event listeners to your containers

vlaaad20:06:32

something along the lines of (fx/make-ext-with-props {:on-width-changed (fx.prop/make (fx.mutator/property-change-listener #(.widthProperty %)) fx.lifecycle/change-listener) ...})

thom20:06:26

nice, will dig into that. ta!

thom21:06:03

ah, good example in e34_web_browser.clj which I missed, apologies. This method works though, thanks!

thom10:06:37

This worked out really nicely btw, even ended up using the sub-ctx stuff to subscribe to the changing width/height and work out the aspect fit for another component. Thanks for the pointers!

👍 2