cljfx

https://github.com/cljfx/cljfx
cjmurphy 2021-01-02T00:13:03.216800Z

Can anyone confirm whether e26-tooltips works (or does not)? For me it doesn't. I get a big black circle but waving the mouse across it has no effect. What should happen is you see a tooltip that tells you the radius of the circle. I'm using JDK 12.0.1 and the "RELEASE" version of cljfx.

2021-01-02T04:16:54.218400Z

@cjmurphy i verified it works for me on the latest cljfx master ... i verified with JDK 11 and 12 on mac os (once i hover, it takes 1-2 seconds for the tooltip to show) hope this helps

cjmurphy 2021-01-02T04:22:18.218600Z

Thank you @atdixon. Yes works for me too I just wasn't being patient enough with holding the mouse still for a good period of time.

👍 1
🙂 1
2021-01-02T19:00:51.219700Z

looking for advice i have a :label that is swapped for :text-field when clicked and i'd like .requestFocus on the :text-field after it is added i've tried ext-on-instance-lifecycle adding a .sceneProperty listener (requesting focus when scene is set on the new text-field), but the scene is updated on other rendering operations so the text-field will re-request focus at inopportune times am wondering if there is a more direct way to achieve this

2021-01-02T19:15:05.221Z

follow up - if i have the listener remove itself after its first firing then this approach seems to work but :on-created doesn't get invoked when i have an :fx/key

2021-01-02T19:15:29.221400Z

but perhaps there's a better way to do focus management ...

vlaaad 2021-01-02T19:39:18.222400Z

@atdixon can you show your composition of :fx/key with ext-on-instance-lifecycle?

vlaaad 2021-01-02T19:39:34.222800Z

wild guess: you might need :on-advanced too

2021-01-02T21:24:55.223600Z

@vlaaad thanks! on-advanced worked really well

👍 1
2021-01-02T21:25:27.224Z

this is roughly the code:

(defn task-row [{:tasks/keys [id name]} editing-id]
  (if (= id editing-id)
    {:fx/type fx/ext-on-instance-lifecycle
     :fx/key id
     :on-advanced #(let [listener
                         (reify ChangeListener
                           (changed [me _ _ v]
                             (doto ^TextField %2
                               .requestFocus
                               .end
                               (-> .sceneProperty
                                 (.removeListener me)))))]
                     (-> ^TextField %2 .sceneProperty
                       (.addListener listener)))
     :desc {:fx/type :text-field
            :text name}}
    {:fx/type fx/ext-on-instance-lifecycle
     :fx/key id
     :on-advanced #(let [listener
                         (reify ChangeListener
                           (changed [me _ _ v]
                             (doto ^Label %2
                               .requestFocus
                               (-> .sceneProperty
                                 (.removeListener me)))))]
                     (-> ^Label %2 .sceneProperty
                       (.addListener listener)))
     :desc {:fx/type :label
            :text name
            :focus-traversable true}}))

2021-01-02T21:25:41.224200Z

i'm only using on-advanced...

2021-01-02T21:26:03.224700Z

on the first creation of the "task row" there's no need to request focus

2021-01-02T21:26:26.225200Z

but when the row goes into editing the :`label` is swapped for :text-field

2021-01-02T21:27:01.225800Z

when the :text-field is swapped back, the same technique is used to keep focus on the :label

2021-01-02T21:28:10.226200Z

...not sure if there's a better way to do this, or if there is danger lurking here 🙂