Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable user to reorder items in new docs-lb listbox by drag and drop

  • Loading branch information...
commit f8761c00f421e65d9ff05178554c55f506a2a6f1 1 parent 674e34f
@jafingerhut jafingerhut authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 src/clj_ns_browser/browser.clj
View
22 src/clj_ns_browser/browser.clj
@@ -601,7 +601,27 @@
(config! (id :ns-lb) :selection-mode :multi-interval) ;; experimental...
(config! (id :vars-lb) :model [])
(config! (id :ns-entries-lbl) :text "0")
- (config! (id :doc-lb) :model doc-lb-value-list)
+ (config! (id :doc-lb)
+ :model doc-lb-value-list
+ :drag-enabled? true
+ :drop-mode :insert
+ :transfer-handler
+ (seesaw.dnd/default-transfer-handler
+ :import [seesaw.dnd/string-flavor
+ (fn [{:keys [target data drop? drop-location] :as m}]
+ ;; Ignore anything dropped onto the list that is
+ ;; not in the original set of list elements.
+ (if (and drop?
+ (:insert? drop-location)
+ (:index drop-location)
+ (doc-lb-value-set data))
+ (let [new-order (list-with-elem-at-index
+ @doc-lb-cur-order data
+ (:index drop-location))]
+ (reset! doc-lb-cur-order new-order)
+ (config! target :model new-order))))]
+ :export {:actions (constantly :copy)
+ :start (fn [c] [seesaw.dnd/string-flavor (selection c)])}))
(config! (id :edit-btn) :enabled? false)
(config! (id :browse-btn) :enabled? false)
(config! (id :clojuredocs-online-rb) :selected? true)
Please sign in to comment.
Something went wrong with that request. Please try again.