Skip to content

Commit

Permalink
Enable user to reorder items in new docs-lb listbox by drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
jafingerhut committed May 17, 2012
1 parent 674e34f commit f8761c0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/clj_ns_browser/browser.clj
Expand Up @@ -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)
Expand Down

0 comments on commit f8761c0

Please sign in to comment.