diff --git a/project.clj b/project.clj index 67be34d..6ecca41 100644 --- a/project.clj +++ b/project.clj @@ -1,6 +1,9 @@ (defproject clojurefx "0.1.0-SNAPSHOT" - :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." + :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. + +**This is not yet on clojars, but it will be there soon. Until then, clone it and install locally.**" :url "https://www.github.com/zilti/clojurefx" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} diff --git a/src/clojurefx/core.clj b/src/clojurefx/core.clj index b1013bd..e2d6cd5 100644 --- a/src/clojurefx/core.clj +++ b/src/clojurefx/core.clj @@ -90,11 +90,21 @@ Don't use this yourself; See the macros \"build\" and \"deffx\" below. (symbol (str k "." (camel (name builder)))))))))) (defmacro build - "This helper macro makes it easier to use the [JavaFX builder classes](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). Example: (build button (text \"Close me.\") (cancelButton true))." + "This helper macro makes it easier to use the [JavaFX builder classes](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). You can also use a map, so it is possible to compose the arguments for the builder over time. + +**Examples:** + + * `(build button (text \"Close me.\") (cancelButton true))` + * `(build button {:text \"Close me.\" :cancelButton true})`" [what & args] - `(.. ~(get-qualified what) create - ~@args - build)) + (if (and (= 1 (count args)) + (map? (first args))) + `(build ~what ~@(for [entry# (keys (first args))] + `(~(symbol (name entry#)) ~((first args) entry#)))) + + `(.. ~(get-qualified what) create + ~@args + build))) (defmacro deffx "Uses build and assigns the result to a symbol."