cljfx

https://github.com/cljfx/cljfx
bartuka 2020-09-24T20:56:35.001500Z

hello, I started to test some ideas with cljfx today and I could not find a way to use webview to loadContent instead of opening an url

bartuka 2020-09-24T20:57:22.002Z

do you guys have some ideas on that?

vlaaad 2020-09-24T21:09:40.002500Z

hmm, I had some snippet somewhere, you need a custom prop for that

bartuka 2020-09-24T21:13:48.004400Z

That would be great, I saw the example in the repo but was not totally clear the directions to go forward

bartuka 2020-09-24T21:13:59.004700Z

Example using url

vlaaad 2020-09-24T21:15:13.005Z

(require '[cljfx.api :as fx]
         '[cljfx.prop :as fx.prop]
         '[cljfx.mutator :as fx.mutator]
         '[cljfx.lifecycle :as fx.lifecycle])

(def ext-with-html
  (fx/make-ext-with-props
    {:html (fx.prop/make
             (fx.mutator/setter #(.loadContent (.getEngine ^javafx.scene.web.WebView %1) %2))
             fx.lifecycle/scalar)}))

(fx/on-fx-thread
  (fx/create-component
    {:fx/type :stage
     :showing true
     :scene {:fx/type :scene
             :root {:fx/type ext-with-html
                    :props {:html "<h1>hello html!</h1>"}
                    :desc {:fx/type :web-view}}}}))

vlaaad 2020-09-24T21:17:01.005600Z

@iagwanderson ^

bartuka 2020-09-24T21:58:53.005900Z

Oh! great! I will test right now

bartuka 2020-09-24T22:09:49.007100Z

Thanks @vlaaad. Works just fine