一位新来的克洛尔。
我想和大家分享一种对我来说很奇怪的行为,但这可能是完全没有问题的。我遵循了关于github https://gist.github.com/daveray/1441520#file-seesaw-repl-tutorial-clj-L381的教程,更准确地说,我应该在标签中添加一个侦听器。让我们创建一个构造函数并显示助手:
(defn make-lb [s]
(listbox :model (-> (symbol s) ns-publics keys sort)))
(defn display [content frame]
(config! frame :content content)
content)这是非常有效的:
(def lb (make-lb "clojure.core"))
(display (scrollable lb) f)
(listen lb :selection (fn [e] (println "Selection is " (selection e))))然而,这并不是:
(def lb (scrollable (make-lb "clojure.core")))
(display lb f)
(listen lb :selection (fn [e] (println "Selection is " (selection e))))注意不同的“可滚动”安置。在第二种情况下,compilier告诉我“未知事件类型:选择seesaw.util/非法-参数(utils.clj:19)"
我看不出为什么第一个片段可以工作,而第二个片段不工作。我对Swing和/或其他Java库一无所知
发布于 2016-09-30 05:20:50
为什么这个不行?(默示)
tl;dr
listbox和scrollable返回不同的东西详细信息
make-lb ):(defn make-lb [s]
(listbox :model (-> (symbol s) ns-publics keys sort)))
(class (make-lb "clojure.core"))
;;=> seesaw.core.proxy$javax.swing.JList$Tag$fd407141
(class (scrollable (make-lb "clojure.core")))
;;=> seesaw.core.proxy$javax.swing.JScrollPane$Tag$fd407141listbox返回一个JList,scrollable返回一个JScrollPanedisplay的调用是等效的listen的调用并不等价。- In the first case, `lb` resolves to a `JList`, and in the second case, `lb` resolves to a `JScrollPane`
更多细节
seesaw.event中查看,我们会看到以下内容:::选择是为每个类专门处理的人工事件。 小部件,所以我们黑了..。
resolve-event-aliases中得到了解决- You'll notice that there's a case for `JList`, but not for `JScrollPane`
JScrollPane的情况下,人工:selection被简单地从对resolve-event-aliases的调用中返回。- Since this isn't a "real selection type", it's only a matter of time before things go pear-shaped
get-or-install-handlers试图查找:selection,什么也得不到,并调用(illegal-argument "Unknown event type %s" event-name),event-name绑定到:selection,这与您收到的异常相匹配。https://stackoverflow.com/questions/39778821
复制相似问题