cljfx

https://github.com/cljfx/cljfx
2020-02-27T14:01:09.045900Z

2020-02-27T14:01:09.046Z

2020-02-27T14:01:56.047Z

it is just a red pane, when you click on it changes it's translate-x and width, but only the :on-layout-bounds-changed listener is firing

2020-02-27T14:02:29.047500Z

no idea why the rest of them aren't

vlaaad 2020-02-27T14:03:05.047900Z

oh, I might know why šŸ™‚

vlaaad 2020-02-27T14:04:25.049Z

That’s probably because the change events are fired during the update, and no event listeners are notified during the update

vlaaad 2020-02-27T14:09:03.053300Z

Take a look at this example:

{:fx/type :text-field
 :on-text-changed prn
 :text "hello world"}
When text field node is being created from this description, cljfx will set text change listener on it, and also it will set the text. But you don’t really want to receive notifications about changes to a text when it’s initially set to ā€œhello worldā€, so I made a decision to not execute any listeners while update is in place. Why would you want to receive notification that pane’s translate-x is set to 300, when you already know in your event handler that it’s set to 300?

vlaaad 2020-02-27T14:10:17.054100Z

With that said, I’m not sure how I feel about that decision. I remember it gave me some troubles a couple of times.

vlaaad 2020-02-27T14:11:34.055800Z

You can try wrapping your pane in this extension lifecycle:

(def ext-with-advance-events
  "Extension lifecycle that notifies all listeners even during advancing
  Expected keys:
  - `:desc` (required) - description of underlying component"
  (reify fx.lifecycle/Lifecycle
    (create [_ {:keys [desc]} opts]
      (binding [fx.lifecycle/*in-progress?* false]
        (fx.lifecycle/create fx.lifecycle/dynamic desc opts)))
    (advance [_ component {:keys [desc]} opts]
      (binding [fx.lifecycle/*in-progress?* false]
        (fx.lifecycle/advance fx.lifecycle/dynamic component desc opts)))
    (delete [_ component opts]
      (binding [fx.lifecycle/*in-progress?* false]
        (fx.lifecycle/delete fx.lifecycle/dynamic component opts)))))

2020-02-27T14:14:32.057900Z

I'm not super sure I need it for this case since it is a minimal example, but was trying to understand the listeners What I'm trying to do is draw a pane with some other panes inside, when the pane is dragged or resized I would like to get the positions of the panes inside, since they are calculated by the layout system (not fixed)

2020-02-27T14:17:35.059200Z

it would also useful if you need to do something when a node position change, in the example above I know what is the position but I don't have a way to do something when the position changes

2020-02-27T14:21:58.059900Z

wrapping it in that lifecycle worked, will use that, thanks !!!

vlaaad 2020-02-27T14:22:15.060200Z

you are welcome šŸ™‚

2020-02-27T14:27:50.062Z

it would be useful to also have a reference to the object when a property change fires soy you can check lets say childs layouts when parent is resized etc

vlaaad 2020-02-27T14:29:16.062400Z

yeah.. I found custom layouts hard to do in cljfx šŸ˜ž

2020-02-27T14:31:36.063300Z

I'm using cljfx for "not the normal stuff" and so far I'm pretty happy with it :simple_smile:

2020-02-27T14:32:07.063800Z

maybe adding those little things enable more use cases

🦜 1