Fixed.
This commit is contained in:
parent
20aac63215
commit
2a6b2511a3
2 changed files with 14 additions and 13 deletions
|
@ -11,20 +11,18 @@ Simple wrapper for Platform/runLater. You should use run-later.
|
||||||
(defmacro run-later [& body]
|
(defmacro run-later [& body]
|
||||||
`(run-later* (fn [] ~@body)))
|
`(run-later* (fn [] ~@body)))
|
||||||
|
|
||||||
(declare ^:dynamic *nested?*)
|
|
||||||
(defn run-now*"
|
(defn run-now*"
|
||||||
A modification of run-later waiting for the running method to return. You should use run-now.
|
A modification of run-later waiting for the running method to return. You should use run-now.
|
||||||
" [f]
|
" [f]
|
||||||
(let [result (promise)]
|
(if (= "JavaFX Application Thread" (.. Thread currentThread getName))
|
||||||
(run-later
|
(apply f [])
|
||||||
(deliver result (try (f) (catch Throwable e e))))
|
(let [result (promise)]
|
||||||
@result))
|
(run-later
|
||||||
|
(deliver result (try (f) (catch Throwable e e))))
|
||||||
|
@result)))
|
||||||
|
|
||||||
(defmacro run-now [& body]
|
(defmacro run-now [& body]
|
||||||
(if *nested?*
|
`(run-now* (fn [] ~@body)))
|
||||||
`((fn [] ~@body))
|
|
||||||
(binding [*nested?* true]
|
|
||||||
`(run-now* (fn [] ~@body)))))
|
|
||||||
|
|
||||||
(defn- camel [in]
|
(defn- camel [in]
|
||||||
(let [in (name in)
|
(let [in (name in)
|
||||||
|
@ -106,7 +104,8 @@ Uses build and assigns the result to a symbol.
|
||||||
|
|
||||||
;; ### Event handling
|
;; ### Event handling
|
||||||
(defmacro add-listener "
|
(defmacro add-listener "
|
||||||
Adds a listener to prop (\"Property\" gets added automatically) of obj, gets the value and passes it to fun.
|
Adds a listener to prop (\"Property\" gets added automatically) of obj, gets the value and passes it to fun.<br/>
|
||||||
|
Example: `(add-listener inputfield focused #(println \"Focus change!\"))`
|
||||||
"[obj prop fun]
|
"[obj prop fun]
|
||||||
`(.. ~obj
|
`(.. ~obj
|
||||||
~(symbol (str (name prop) "Property"))
|
~(symbol (str (name prop) "Property"))
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
(:require [clojure.test :refer :all]
|
(:require [clojure.test :refer :all]
|
||||||
[clojurefx.core :refer :all]))
|
[clojurefx.core :refer :all]))
|
||||||
|
|
||||||
(deftest a-test
|
(deftest runnow
|
||||||
(testing "FIXME, I fail."
|
(testing "Uses correct thread"
|
||||||
(is (= 0 1))))
|
(is (= javafx.scene.Scene (type (build scene {})))))
|
||||||
|
(testing "Nested run-nows"
|
||||||
|
(is (= javafx.scene.Scene (type (build scene {:root (build v-box {})}))))))
|
||||||
|
|
Loading…
Reference in a new issue