listener macro
This commit is contained in:
parent
82f84222de
commit
3bd58af56a
2 changed files with 21 additions and 11 deletions
|
@ -89,25 +89,34 @@ Don't use this yourself; See the macros \"build\" and \"deffx\" below.
|
|||
(if (not (empty? (filter #(= % builder) (get pkgs k))))
|
||||
(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). You can also use a map, so it is possible to compose the arguments for the builder over time.
|
||||
(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). 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]
|
||||
* `(build button {:text \"Close me.\" :cancelButton true})`
|
||||
"[what & args]
|
||||
(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
|
||||
`(run-now (.. ~(get-qualified what) ~(symbol "create")
|
||||
~@args
|
||||
build)))
|
||||
~(symbol "build")))))
|
||||
|
||||
(defmacro deffx
|
||||
"Uses build and assigns the result to a symbol."
|
||||
[name what & args]
|
||||
`(def ~name
|
||||
(defmacro deffx "
|
||||
Uses build and assigns the result to a symbol.
|
||||
"[name what & args]
|
||||
`(def ~name
|
||||
(build ~what ~@args)))
|
||||
|
||||
;; # 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]
|
||||
`(.. ~obj
|
||||
~(symbol (str (name prop) "Property"))
|
||||
(addListener (reify javafx.beans.value.ChangeListener
|
||||
(changed [c#]
|
||||
(~fun (.getValue c#)))))))
|
||||
|
|
1
target/repl/stale/extract-native.dependencies
Normal file
1
target/repl/stale/extract-native.dependencies
Normal file
|
@ -0,0 +1 @@
|
|||
([:dependencies ([org.clojure/clojure "1.5.1"] [com.oracle/javafx-runtime "2.2.0"] [org.clojure/tools.nrepl "0.2.3"] [clojure-complete/clojure-complete "0.2.3"])])
|
Loading…
Reference in a new issue