0.0.30-SNAPSHOT
This commit is contained in:
parent
df28a1c96b
commit
60273fc665
5 changed files with 18 additions and 8 deletions
12
README.md
12
README.md
|
@ -1,12 +1,12 @@
|
|||
[![License](//img.shields.io/badge/license-LGPL-blue.svg?style=flat)](https://www.gnu.org/licenses/lgpl-3.0.en.html#content)
|
||||
[![Clojars](//img.shields.io/badge/clojars-0.0.21--SNAPSHOT-blue.svg?style=flat)](https://clojars.org/clojurefx/versions/0.0.21-SNAPSHOT)
|
||||
[![Clojars](//img.shields.io/badge/clojars-0.0.30--SNAPSHOT-blue.svg?style=flat)](https://clojars.org/clojurefx/versions/0.0.30-SNAPSHOT)
|
||||
[![Gratipay](//img.shields.io/gratipay/zilti.svg?style=flat)](//gratipay.com/zilti)
|
||||
[![Flattr this](//api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=zilti&url=https%3A%2F%2Fbitbucket.org%2Fzilti%2Fclojurefx)
|
||||
|
||||
# ClojureFX
|
||||
|
||||
```clojure
|
||||
[clojurefx "0.0.21-SNAPSHOT"]
|
||||
[clojurefx "0.0.30-SNAPSHOT"]
|
||||
```
|
||||
|
||||
**Note: This is a complete rewrite, no code has been taken over from the old version on GitHub, and I'm taking a radically different approach.**
|
||||
|
@ -24,9 +24,13 @@ This is in a very early state, so there isn't much yet. Take a look at the [Cloj
|
|||
### Declarative UI programming
|
||||
|
||||
```clojure
|
||||
(def superbutton (compile [Button {:text "Close"
|
||||
:action #'close-handler}]))
|
||||
|
||||
(compile [VBox {:id "TopLevelVBox"
|
||||
:children [Label {:text "Hi!"}
|
||||
Label {:text "I'm ClojureFX!"}
|
||||
HBox {:id "HorizontalBox"
|
||||
:children [Button {:text "Alright."}]}]}])
|
||||
```
|
||||
:children [Button {:text "OK"}
|
||||
superbutton]}]}])
|
||||
```
|
||||
|
|
|
@ -190,9 +190,11 @@ nil)
|
|||
(tc-ignore
|
||||
(extend-protocol p/FXOnAction
|
||||
ButtonBase
|
||||
(get-action [this] (.getOnAction ^ButtonBase this))
|
||||
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
|
||||
(fire! [this] (.fire this))
|
||||
MenuItem
|
||||
(get-action [this] (.getOnAction ^MenuItem this))
|
||||
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
|
||||
(fire! [this] (.fire this))))
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
:children (with-meta [#'get-subnodes #'set-subnodes!] {:argument java.util.List :parent FXParent})
|
||||
;;; FXStyleSetter / FXStyleable
|
||||
:style (with-meta [#'get-style #'set-style!] {:argument String :parent FXStyleable})
|
||||
;;; FXOnAction
|
||||
:action (with-meta [#'get-action #'set-action!] {:argument clojure.lang.IFn :parent FXOnAction})
|
||||
;;; FXStage
|
||||
:title (with-meta [#'get-title #'set-title!] {:argument String :parent FXStage})
|
||||
:scene (with-meta [#'get-scene #'set-scene!] {:argument Scene :parent FXStage})
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
|
||||
(defprotocol [[A :variance :covariant]]
|
||||
FXOnAction
|
||||
(get-action [this :- A] :- [javafx.event.EventHandler -> Any])
|
||||
(set-action! [this :- A action :- [javafx.event.EventHandler -> Any]] :- A)
|
||||
(fire! [this :- A] :- nil))
|
||||
|
||||
|
|
|
@ -11,13 +11,14 @@
|
|||
;;## Element testing
|
||||
|
||||
;;## Event testing
|
||||
(def button (new Button))
|
||||
;;(def button (new Button))
|
||||
(def button (atom nil))
|
||||
(def fired? (atom false))
|
||||
(facts "Events"
|
||||
(fact "Adding an event handler"
|
||||
(set-action! button (fn [event] (reset! fired? true))) => button)
|
||||
(fact "Creating button with event handler"
|
||||
(class (reset! button (factory/compile [Button {:action (fn [_] (reset! fired? true))}]))) => javafx.scene.control.Button)
|
||||
(fact "Firing the event and checking the result"
|
||||
(do (fire! button)
|
||||
(do (fire! @button)
|
||||
@fired?) => true))
|
||||
|
||||
;;## IdMapper
|
||||
|
|
Loading…
Reference in a new issue