如何使对话功能起作用

问题描述 投票:0回答:1

我想打开一个对话框,并在对话框返回ok后处理数据。问题是:提交对话框后不会调用success-fn。这与按钮中的监听器有关。如果在没有侦听器的情况下调用connectDialog,则调用函数:success-fn。

码:

(def dbConnectionForm
  (grid-panel :columns 2
              :items ["Database Driver" (combobox :id :dbdriver :model ["postgresql" "mysql"])
                      "Database"        (text :id :dbname :text "postgres")
                      "Port"            (text :id :dbport :text "32768")
                      "Username"        (text :id :username :text "postgres")
                      "Password"        (text :id :password :text "postgres")]))

(defn connectionDialog []
  (print (-> (dialog
    :content dbConnectionForm
    :option-type :ok-cancel
    :type :plain
    :success-fn (fn [e] (print (value dbConnectionForm)))
    )pack! show!))
  )

(def connectButton (button :text "Connect"
                           :listen [:action (fn [e] (connectionDialog))]))
clojure dialog seesaw
1个回答
1
投票

这可能是因为你正在使用print。将其更改为println或在flush之后在回调中添加对print的调用。

如果(value dbConnectionForm)返回一个较小的值(如转换为String只有几个字符的东西),并且不包含换行符,则可能不会提示outstream自动刷新,因此文本卡在缓冲区中。

© www.soinside.com 2019 - 2024. All rights reserved.