Fork me on GitHub
#cljfx
<
2022-02-25
>
hairfire14:02:35

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.

vlaaad14:02:55

yeah, that situation sucks

vlaaad14:02:15

I have a workaround perhaps... let me find it...

😀 1
hairfire14:02:57

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.

vlaaad14:02:27

this lifecycle makes all listeners in desc and its children to receive all change events

vlaaad14:02:16

you probably want that only for the stage, but not for components on that stage

vlaaad14:02:04

You can probably achieve that with ext-let-refs...

vlaaad14:02:12

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}}}}

vlaaad14:02:58

sorry this behavior requires so much black magic

hairfire14:02:25

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.

👍 1
hairfire18:02:35

How can I get the stage "client" width? I want to scale components based on this width.

vlaaad18:02:01

I usually put it into state, e.g. select some default and add on-width/height-changed listeners

👍 1
hairfire18:02:41

Is there a way to get a reference to the scene JavaFX object?

hairfire18:02:18

It looks like "instance" will do it. Now I just need to figure out how to use "instance".

vlaaad06:02:56

Sometimes fx/ext-on-instance-lifecycle with :on-created is enough