cljfx

https://github.com/cljfx/cljfx
pbaille 2021-02-11T09:34:02.025200Z

Hello! I'm trying cljfx those days πŸ™‚ it is really great work!

pbaille 2021-02-11T09:39:51.027400Z

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 "<https://raw.githubusercontent.com/FirebaseExtended/firepad/master/examples/code.html>"))

(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 πŸ™‚

vlaaad 2021-02-11T10:04:24.029Z

@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: '&lt;API_KEY&gt;',
        authDomain: "<http://firepad-gh-tests.firebaseapp.com|firepad-gh-tests.firebaseapp.com>",
        databaseURL: "<https://firepad-gh-tests.firebaseio.com>"
      };
maybe you need to use correct API key for that page to show anything?

pbaille 2021-02-11T10:06:26.030500Z

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

pbaille 2021-02-11T10:07:59.031200Z

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

vlaaad 2021-02-11T10:08:59.031400Z

nope 😞