我想打开一个对话框,并在对话框返回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))]))发布于 2018-01-03 14:17:40
这可能是因为您正在使用print。将其更改为println,或在print之后的回调中添加对flush的调用。
如果(value dbConnectionForm)返回一个很小的值(比如当转换为字符串时只有几个字符),并且不包含换行符,它可能不会提示外部流自动刷新,因此文本被卡在缓冲区中。
https://stackoverflow.com/questions/48078108
复制相似问题