cljfx

hairfire 2022-02-25T14:29:35.000759Z

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.

vlaaad 2022-02-25T14:37:55.308249Z

yeah, that situation sucks

vlaaad 2022-02-25T14:38:15.715249Z

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

😀 1
hairfire 2022-02-25T14:41:57.768359Z

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.

vlaaad 2022-02-25T14:49:27.810059Z

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

vlaaad 2022-02-25T14:50:16.302969Z

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

vlaaad 2022-02-25T14:52:04.402359Z

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

vlaaad 2022-02-25T14:52:12.514289Z

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

vlaaad 2022-02-25T14:52:58.053239Z

sorry this behavior requires so much black magic

hairfire 2022-02-25T14:55:25.663669Z

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
hairfire 2022-02-25T18:05:35.526889Z

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

vlaaad 2022-02-25T18:09:01.312059Z

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

👍 1
hairfire 2022-02-25T18:14:41.935089Z

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

hairfire 2022-02-25T18:20:18.656729Z

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

vlaaad 2022-02-26T06:27:56.364939Z

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