0.1.0-SNAPSHOT permalink Arrow_down_16x16



  • (tree-example)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clj_swing/example.clj:71 top

(defn tree-example []
  (let [sr (ref "")
	m (ref {{:name "Cookies"} {{:name "Chocolat"} 1 {:name "Vanilla"} { {:name "with sparkles"} 2 {:name "without sparkles"} 3}}})
	path (atom nil)]
  (frame :title "Tree example" :show true :size [400 200]
	 [_ (stack
	     [tf (text-field :str-ref sr)
	      _ (tree
		 :name tr
		 :action ([old new]
			    (prn (.getSelectionPath tr))
			    (if new
			       (swap! path (constantly new))
			       (alter sr (constantly (:name (last new)))))))
		 :model (mapref-tree-model m {:name "Food"}
					   :node-wrapper (fn [node path] (Pathed. node (str (:name node)) path))))]
		  (let [c (get-in @m @path)]
		    (prn 10 c @sr @m)
		    (if-let [r (butlast @path)]
			(alter m update-in r dissoc (last @path))
			(alter m update-in r assoc {:name @sr} c))
			(alter m dissoc (last @path))
			(alter m assoc {:name @sr} c)))))
		 (prn @m))))])))
Vars in clj-swing.example/tree-example: defn let
Used in 0 other vars

Comments top

No comments for tree-example. Log in to add a comment.