                                                                                                       :live-objects {})
                                                                                         :mouse-down-loc [wx wy]
                                                                                         :last-loc [wx wy]
-                                                                                        :move-mode :clicking)]
-                                                                               (if-let [new-sel (first found-things)]
-                                                                                 (if (.-shiftKey evt)
-                                                                                   (if (contains? sel new-sel)
-                                                                                     (selection-remove ed new-sel)
-                                                                                     (selection-add ed wld new-sel))
-                                                                                   (selection-add (selection-init ed) wld new-sel))
-                                                                                 (if (.-shiftKey evt)
-                                                                                   ed
-                                                                                   (selection-init ed))))))))
+                                                                                        :move-mode :clicking)
+                                                                                   shift? (.-shiftKey evt)
+                                                                                   new-sel (first found-things)
+                                                                                   present? (and new-sel
+                                                                                                 (contains? sel new-sel))]
+                                                                               (cond
+                                                                                 ; shift-clicked on an object already present --> deselect
+                                                                                 (and new-sel shift? present?)
+                                                                                 (selection-remove ed new-sel)
+                                                                                 ; shift-clicked on a new object --> add to selection
+                                                                                 (and new-sel shift?)
+                                                                                 (selection-add ed wld new-sel)
+                                                                                 ; regular-clicked on a new object --> change selection to new object
+                                                                                 (and new-sel (not shift?) (not present?))
+                                                                                 (selection-add (selection-init ed)
+                                                                                                wld
+                                                                                                new-sel)
+                                                                                 ; regular-clicked on nothing --> clear selection
+                                                                                 (and (not new-sel)
+                                                                                      (not shift?))
+                                                                                 (selection-init ed)
+                                                                                 ; otherwise (eg regular clicked on a selected object), do nothing
+                                                                                 :else
+                                                                                 ed))))))
                                                   :onMouseMove
                                                          (fn [evt]
                                                            (let [ed @editor

(defn button-bar [world]
  (let [wld @world
        ha-defs (:ha-defs wld)]
    (sab/html [:div {:style {:position "fixed"}}
               [:button {:onClick #(swap! world
                                          (fn [w]
                                            (assoc w :playing (not (:playing w)))))}

                                                                               ;create new object and set sel to it and enter either moving state (for HAs) or resizing state (for walls)
                                                                               ; multi-selection or HA selected or mouse in center
                                                                               (editor-start-new-thing ed down-x down-y wx wy)
                                                                               (or (> (count sel) 1)
                                                                                   (= :objects (ffirst sel))
                                                                                   (= :live-objects (ffirst sel))
                                                                                   (wall-centerish-point? (get-in (:draft-desc ed) (first sel)) wx wy))
