When I try to add a stylesheet with cljfx css, components no longer work for me, running any code which should show a view fails silently, and no longer works until I restart the jvm, even if i remove the stylesheet from the scene afterwards. Does this sound familiar to anyone? I'm on windows and java 13
(def style
(css/register ::style
(let [padding 10
text-color "#111111"]
;; you can put style settings that you need to access from code at keyword keys in a
;; style map and access them directly in an app
{::padding padding
::text-color text-color
;; string key ".root" defines `.root` selector with these rules: `-fx-padding: 10;`
".root" {:-fx-padding padding}
".label" {:-fx-text-fill text-color
:-fx-wrap-text true}
".button" {:-fx-text-fill text-color
;; vector values are space-separated
:-fx-padding ["4px" "8px"]
;; nested string key defines new selector: `.button:hover`
":hover" {:-fx-text-fill :black}}})))
(fx/on-fx-thread
(fx/create-component
{:fx/type :stage
:showing true
:title "Cljfx example"
:width 300
:height 100
:scene {:fx/type :scene
:stylesheets [(::css/url style)]
:root {:fx/type :v-box
:alignment :center
:children [{:fx/type :label
:text "Hello world"}]}}}))
Ok I finally tracked this down. By default I use a repl that starts a sub-repl that uses fipp
as a printer, like this
(binding [*print-length* 20
*print-level* 10]
(main/repl
:caught pst
:print fipp
))
For some reason, this is what was causing the issue with the stylesheet. If I remove this it works.hmm, I have no idea how that could affect the css...
was that because of subrepl, or because of fipp printer?
Oh yeah, good point, it's due to the subrepl. it fails being called after (main/repl)
. For what it's worth I'm using inf-clojure in emacs
I can't quit emacs 😄
actually, I can
but I only used spacemacs, and still have PTSD from how broken it is all the time
I feel the same way 🙂 I've tried every other editor but nothing else sticks with me
@jjttjj - your code worked for me when I added :style-class ["label"] to the label node my env: Win10, Java 14.0.2 cljfx 1.7.10, clojure 1.10.1 :scene {:fx/type :scene :stylesheets [(::css/url style)] :root {:fx/type :v-box :alignment :center :children [{:fx/type :label :style-class ["label"] :text "Hello world"}]}}
hmm, still not working for me
I have never seen anything like that
What is the result of evaluating (System/getProperty "java.protocol.handler.pkgs" "")
?
"|cljfx.css"
hmm
can you try setting it to just cljfx.css
?
Sure one sec
Still nothing
hmm, maybe there are some error logs somewhere? 🙂
I tried the code on windows with java 14 and it works...
Yeah I'm wondering where the errors are going haha. I can try Java 14 out later tonight
what version of java 13 do you use? 13? 13.0.1? 13.0.2?
13.0.1
Worked for me on windows with 13.0.1 JDK:
PS C:\Users\Vlaaad> clj -Sdeps "{:deps {cljfx/cljfx {:mvn/version """"1.7.10""""} cljfx/css {:mvn/version """"1.1.0""""}}}"
Clojure 1.10.1
user=> (System/getProperty "java.version")
"13.0.1"
user=> (require '[cljfx.css :as css] '[cljfx.api :as fx])
nil
user=> (def style
(css/register ::style
(let [padding 10
text-color "#ff1111"]
;; you can put style settings that you need to access from code at keyword keys in a
;; style map and access them directly in an app
{::padding padding
::text-color text-color
;; string key ".root" defines `.root` selector with these rules: `-fx-padding: 10;`
".root" {:-fx-padding padding}
".label" {:-fx-text-fill text-color
:-fx-wrap-text true}
".button" {:-fx-text-fill text-color
;; vector values are space-separated
:-fx-padding ["4px" "8px"]
;; nested string key defines new selector: `.button:hover`
":hover" {:-fx-text-fill :black}}})))
#'user/style
user=> (fx/on-fx-thread
(fx/create-component
{:fx/type :stage
:showing true
:title "Cljfx example"
:width 300
:height 100
:scene {:fx/type :scene
:stylesheets [(::css/url style)]
:root {:fx/type :v-box
:alignment :center
:children [{:fx/type :label
:text "Hello world"}]}}}))
#object[clojure.lang.Delay 0x373052b5 {:status :pending, :val nil}]
user=>
I downloaded the JDK from here https://jdk.java.net/archive/
Thanks for all the research! I'll take another look at it in a bit, I'm probably doing something dumb