Fork me on GitHub
#cljfx
<
2021-02-11
>
pbaille09:02:02

Hello! I'm trying cljfx those days 🙂 it is really great work!

pbaille09:02:51

I'm trying to use webviews, but I'm struggling a bit, here is my code (based on exemple 39) I'm trying to render an https://github.com/FirebaseExtended/firepad/blob/master/examples/ace.html from the https://firepad.io/ website

(ns moi.firepad
  (:require [cljfx.api :as fx]
            [cljfx.ext.web-view :as fx.ext.web-view])
  (:import [javafx.scene.web WebEvent]))

;; this example shows how to use web view extensions that provide access to
;; WebEngine object that is used for obtaining web page information and
;; controlling it

(def *state
  (atom
   {:title nil
    :status nil}))

(def html
  (slurp ""))

(defn view [{:keys [title status]}]
  {:fx/type :stage
   :showing true
   :title (str title)
   :scene
            {:fx/type :scene
             :root
                      {:fx/type :v-box
                       :children
                                [{:fx/type fx.ext.web-view/with-engine-props
                                  :desc {:fx/type :web-view}
                                  :props {:content html
                                          :on-title-changed #(swap! *state assoc :title %)
                                          :on-status-changed #(swap! *state assoc :status (.getData ^WebEvent %))}}
                                 {:fx/type :label
                                  :text (str status)}]}}})

(def renderer
  (fx/create-renderer
   :middleware (fx/wrap-map-desc #'view)))

(fx/mount-renderer *state renderer)
It renders a blank window, I don't know what is going on... any help would be appreciated 🙂

vlaaad10:02:24

@pbaille I haven’t tried to run it, but your html contains this:

//// Initialize Firebase.
      //// TODO: replace with your Firebase project configuration.
      var config = {
        apiKey: '<API_KEY>',
        authDomain: "",
        databaseURL: ""
      };
maybe you need to use correct API key for that page to show anything?

pbaille10:02:26

Ho! my bad, I have not seen that! I will try again. thank you a lot

pbaille10:02:59

Is there a way to have some kind of devtools within web views ?

vlaaad10:02:59

nope 😞