It would be perfect if this could be executed when the scene is shown (i.e., An on-shown event handler), but on-shown is never triggered (See https://github.com/cljfx/cljfx/issues/138). I tried the suggestion https://github.com/cljfx/hn/blob/master/src/hn/core.clj#L51, but it still takes a couple of seconds for the stage/scene to render after the splash screen is closed. I finally settled on just waiting a few seconds, and then closing the splash screen.
yeah, that situation sucks
I have a workaround perhaps... let me find it...
I was thinking I could render the stage with :showing as a subscription to a boolean, initially false, then after some timeout period close the splash screen, and change the boolean to true.
https://github.com/defold/defold/blob/editor-dev/editor/src/clj/editor/fxui.clj#L72-L86
this lifecycle makes all listeners in desc and its children to receive all change events
you probably want that only for the stage, but not for components on that stage
You can probably achieve that with ext-let-refs...
e.g.:
{:fx/type fx/ext-let-refs
:refs {::scene {:fx/type :scene ...}}
:desc {:fx/type ext-with-advance-events
:desc {:fx/type :stage
:on-shown ...
:scene {:fx/type fx/ext-get-ref
:ref ::scene}}}}sorry this behavior requires so much black magic
Thank you. No need to be sorry! You've done great work on cljfx. It's making my .NET C# development colleagues take a closer look at Clojure.
How can I get the stage "client" width? I want to scale components based on this width.
I usually put it into state, e.g. select some default and add on-width/height-changed listeners
Is there a way to get a reference to the scene JavaFX object?
It looks like "instance" will do it. Now I just need to figure out how to use "instance".
Sometimes fx/ext-on-instance-lifecycle with :on-created is enough