0

i'm trying to make a EventHandler for my FXML based View in my Clojure Projekt. As described here: http://drowsy.de/blog/?p=7 i added in the FXML this

onAction="(use 'ui.listener) (add-tolist-listener event)"

to a button.

But when i launch the application i get following error message:

LoadException Error resolving onAction='(use 'ui.listener)
(add-tolist-listener event)', either the event handler is not in 
the Namespace or there is an error in the script.

In ui.listener is the eventhandler

(defn add-tolist-listener [event]
(println "I'm a Button"))

Any idea why this doesn't work? I tried it with this notation

onAction = #add-tolist-listener

and it didn't worked too.

Thanks!

GameYoker
  • 55
  • 7

2 Answers2

0

I am completely unfamiliar with JavaFX, however:

onAction="(use 'ui.listener) (add-tolist-listener event)"

This looks like Java code, so having Clojure syntax in here doesn't seem like it would work? I suspect you would have to call your Clojure code using Java?

Going off "Calling Clojure code from Java".

You would have to try something like:

ui.listener.add_tolist_listener

You might also find this blog post gives you another idea to try: Invoking Clojure code from Java.

Community
  • 1
  • 1
Mike
  • 3,356
  • 3
  • 29
  • 27
  • ui.listener.add_tolist_listener doesn't work too... No, i set up the gui only with Clojure, i don't call Clojure with Java – GameYoker Jan 05 '17 at 10:27
0

Now is set up the action in my start function via

(.setOnAction (.lookup root "#startCalculationBtn")
  (proxy [EventHandler] []
    (handle [^ActionEvent event]
      (start-calculation))
    )
  )

And it works.

GameYoker
  • 55
  • 7