i have an :on-focused-changed
handler that needs reference to the Node
itself
so i reify
a ChangeListener
:
:fx/type :label
:on-focused-changed
(reify ChangeListener
(changed [_this o _ new-val]
(let [^Label label (.getBean ^ReadOnlyProperty o)]
...do stuff with label...)
...??? dispatch another event ???...))
but at the end of the event handling i'd like to dispatch another eventmy thinking is that i'll just thread my event-handler
into my view functions, and directly invoke it
does that seem reasonable?
what do you need node access for?
@vlaaad when a node in a scroll pane gains focus, i want to check its bounds and if it's not in view, update the scroll pane to bring it into view
i've got that part working but then need to dispatch an event after this (along the lines of the code structure i posted above)
alternatively, if there were a way to have the source node carry with the event, that would allow me to do it all in an event handler... something like this perhaps ? ->
:on-focused-changed {::event/type ::event/handle-focus-change :node <???get-node-ref???>
@atdixon yeah I see wat you want, and I think this is a weak spot in cljfx — passing stuff from cljfx env to event listeners
All I can offer is a hack: use (fx/make-ext-with-props cljfx.fx.node/props)
to create an extension lifecycle that allows specifying any node props. Then you can setup :on-focus-changed
twice: first on the node description with your reified change listener, second in extension lifecycle with event dispatch
e.g.
(def ext-with-node-props (fx/make-ext-with-props fx.node/props))
{:fx/type ext-with-node-props
:props {:on-focused-changed {:my-event ::foo}}
:desc {:fx/type :label
:on-focused-changed (reify ...)}}