cljfx

thom 2021-10-17T21:18:59.021100Z

should I expect setting a :style-class in a :cell-factory (in a table view in this case) to work? I'm not seeing them getting set properly right now. I'm led to believe JavaFX does allow individual cells to have their own classes.

vlaaad 2021-10-18T09:23:19.021200Z

I would expect style classes to work, can you share an example?

vlaaad 2021-10-18T09:28:25.021400Z

This works for me:

(require '[cljfx.css :as css]
         '[cljfx.api :as fx])

(def css-url
  (::css/url (css/register ::css {".red" {:-fx-text-fill :red}
                                  ".green" {:-fx-text-fill :green}})))

(fx/on-fx-thread
  (fx/create-component
    {:fx/type :stage
     :showing true
     :scene {:fx/type :scene
             :stylesheets [css-url]
             :root {:fx/type :table-view
                    :columns [{:fx/type :table-column
                               :cell-value-factory identity
                               :cell-factory {:fx/cell-type :table-cell
                                              :describe (fn [x]
                                                          {:text (str x)
                                                           :style-class (name x)})}}]
                    :items [:red :green]}}}))

thom 2021-10-18T09:50:09.022200Z

Ahh, I'm setting it one level up alongside the cell type. That explains it, thanks!

👍 1