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
|
||||
/lib/
|
||||
/classes/
|
||||
/targets/
|
||||
/target/
|
||||
.lein-deps-sum
|
||||
*~
|
||||
*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.
|
||||
|
||||
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.))
|
||||
|
||||
(defn run-later*
|
||||
"Simple wrapper for Platform/runLater. You should use run-later."
|
||||
[f]
|
||||
(defn run-later*"
|
||||
Simple wrapper for Platform/runLater. You should use run-later.
|
||||
" [f]
|
||||
(javafx.application.Platform/runLater f))
|
||||
|
||||
(defmacro run-later
|
||||
[& body]
|
||||
(defmacro run-later [& body]
|
||||
`(run-later* (fn [] ~@body)))
|
||||
|
||||
(defn run-now*
|
||||
"A modification of run-later waiting for the running method to return. You should use run-now."
|
||||
[f]
|
||||
(defn run-now*"
|
||||
A modification of run-later waiting for the running method to return. You should use run-now.
|
||||
" [f]
|
||||
(let [result (promise)]
|
||||
(run-later
|
||||
(deliver result (try (f) (catch Throwable e e))))
|
||||
@result))
|
||||
|
||||
(defmacro run-now
|
||||
[& body]
|
||||
(defmacro run-now [& 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]
|
||||
(let [in (name in)
|
||||
in (str/split in #"-")
|
||||
|
@ -111,7 +101,7 @@ Uses build and assigns the result to a symbol.
|
|||
`(def ~name
|
||||
(build ~what ~@args)))
|
||||
|
||||
;; # Event handling
|
||||
;; ### Event handling
|
||||
(defmacro add-listener "
|
||||
Adds a listener to prop (\"Property\" gets added automatically) of obj, gets the value and passes it to 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
|
||||
(changed [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