From 1e09debdcca36a9a39cd064e116ad96e6c7ca6be Mon Sep 17 00:00:00 2001 From: "dziltener@lyrion.ch" Date: Fri, 30 Aug 2013 07:47:56 +0000 Subject: [PATCH] First clojars release --- .gitignore | 2 +- project.clj | 2 +- src/clojurefx/core.clj | 35 ++++++++++++++++------------------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index da1beee..710585d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ pom.xml *jar /lib/ /classes/ -/targets/ +/target/ .lein-deps-sum *~ *class diff --git a/project.clj b/project.clj index 6ecca41..9ce7ffc 100644 --- a/project.clj +++ b/project.clj @@ -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. diff --git a/src/clojurefx/core.clj b/src/clojurefx/core.clj index 7d04d3d..497fb27 100644 --- a/src/clojurefx/core.clj +++ b/src/clojurefx/core.clj @@ -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)))