a new to Clojure here.
I would like to share a behaviour which seems strange to me, but may be it's totally ok. I followed the tutorial on github https://gist.github.com/daveray/1441520#file-seesaw-repl-tutorial-clj-L381 , and more precisely the part where I am supposed to add a Listener to a Label. Let's make a constructor and display helper:
(defn make-lb [s]
(listbox :model (-> (symbol s) ns-publics keys sort)))
(defn display [content frame]
(config! frame :content content)
content)
This works perfectly:
(def lb (make-lb "clojure.core"))
(display (scrollable lb) f)
(listen lb :selection (fn [e] (println "Selection is " (selection e))))
Howevever, this doesn't:
(def lb (scrollable (make-lb "clojure.core")))
(display lb f)
(listen lb :selection (fn [e] (println "Selection is " (selection e))))
Notice the different "Scrollable" emplacement. In the second case, compilier tells me "Unknown event type :selection seesaw.util/illegal-Argument (utils.clj:19)"
I don't see any reason why the first snippet works, and the second doesn't. I don't have any knowledge of Swing and/or other Java libraries
tl;dr
listboxandscrollablereturn different thingsDetails
make-lbincluded for clarity):For our purposes, we'll just say that
listboxreturns aJListandscrollablereturns aJScrollPaneGiven that, the calls to
displayare equivalentHowever, the calls to
listenare not equivalentlbresolves to aJList, and in the second case,lbresolves to aJScrollPaneMore details
seesaw.event, we'd see the following:What I'll call a "real selection type" is resolved in
resolve-event-aliasesJList, but not forJScrollPaneIn the
JScrollPanecase, the artificial:selectionis simply handed back from the call toresolve-event-aliasesAnd sure enough,
get-or-install-handlersattempts to look up:selection, gets nothing back, and calls(illegal-argument "Unknown event type %s" event-name)whereevent-nameis bound to:selection, which matches the exception that you were receiving