First clojars release
This commit is contained in:
parent
6dd053fa87
commit
1e09debdcc
3 changed files with 18 additions and 21 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,7 +2,7 @@ pom.xml
|
||||||
*jar
|
*jar
|
||||||
/lib/
|
/lib/
|
||||||
/classes/
|
/classes/
|
||||||
/targets/
|
/target/
|
||||||
.lein-deps-sum
|
.lein-deps-sum
|
||||||
*~
|
*~
|
||||||
*class
|
*class
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject clojurefx "0.1.0-SNAPSHOT"
|
(defproject clojurefx "0.0.1"
|
||||||
:description "Helper functions and probably a wrapper to simplify usage of JavaFX in Clojure.
|
:description "Helper functions and probably a wrapper to simplify usage of JavaFX in Clojure.
|
||||||
|
|
||||||
You'll need to have jfxrt.jar in your local maven repository. See [this coderwall protip](https://coderwall.com/p/4yjy1a) for how to make this happen.
|
You'll need to have jfxrt.jar in your local maven repository. See [this coderwall protip](https://coderwall.com/p/4yjy1a) for how to make this happen.
|
||||||
|
|
|
@ -3,35 +3,25 @@
|
||||||
|
|
||||||
(defonce force-toolkit-init (javafx.embed.swing.JFXPanel.))
|
(defonce force-toolkit-init (javafx.embed.swing.JFXPanel.))
|
||||||
|
|
||||||
(defn run-later*
|
(defn run-later*"
|
||||||
"Simple wrapper for Platform/runLater. You should use run-later."
|
Simple wrapper for Platform/runLater. You should use run-later.
|
||||||
[f]
|
" [f]
|
||||||
(javafx.application.Platform/runLater f))
|
(javafx.application.Platform/runLater f))
|
||||||
|
|
||||||
(defmacro run-later
|
(defmacro run-later [& body]
|
||||||
[& body]
|
|
||||||
`(run-later* (fn [] ~@body)))
|
`(run-later* (fn [] ~@body)))
|
||||||
|
|
||||||
(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)]
|
(let [result (promise)]
|
||||||
(run-later
|
(run-later
|
||||||
(deliver result (try (f) (catch Throwable e e))))
|
(deliver result (try (f) (catch Throwable e e))))
|
||||||
@result))
|
@result))
|
||||||
|
|
||||||
(defmacro run-now
|
(defmacro run-now [& body]
|
||||||
[& body]
|
|
||||||
`(run-now* (fn [] ~@body)))
|
`(run-now* (fn [] ~@body)))
|
||||||
|
|
||||||
(defn event-handler*
|
|
||||||
[f]
|
|
||||||
(reify javafx.event.EventHandler
|
|
||||||
(handle [this e] (f e))))
|
|
||||||
|
|
||||||
(defmacro event-handler [arg & body]
|
|
||||||
`(event-handler* (fn ~arg ~@body)))
|
|
||||||
|
|
||||||
(defn- camel [in]
|
(defn- camel [in]
|
||||||
(let [in (name in)
|
(let [in (name in)
|
||||||
in (str/split in #"-")
|
in (str/split in #"-")
|
||||||
|
@ -111,7 +101,7 @@ Uses build and assigns the result to a symbol.
|
||||||
`(def ~name
|
`(def ~name
|
||||||
(build ~what ~@args)))
|
(build ~what ~@args)))
|
||||||
|
|
||||||
;; # 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.
|
||||||
"[obj prop fun]
|
"[obj prop fun]
|
||||||
|
@ -120,3 +110,10 @@ Adds a listener to prop (\"Property\" gets added automatically) of obj, gets th
|
||||||
(addListener (reify javafx.beans.value.ChangeListener
|
(addListener (reify javafx.beans.value.ChangeListener
|
||||||
(changed [c#]
|
(changed [c#]
|
||||||
(~fun (.getValue c#)))))))
|
(~fun (.getValue c#)))))))
|
||||||
|
|
||||||
|
(defn event-handler* [f]
|
||||||
|
(reify javafx.event.EventHandler
|
||||||
|
(handle [this e] (f e))))
|
||||||
|
|
||||||
|
(defmacro event-handler [arg & body]
|
||||||
|
`(event-handler* (fn ~arg ~@body)))
|
||||||
|
|
Loading…
Reference in a new issue