From a1b28c1317be75d98a2ef409fb6d5d1068b9f90e Mon Sep 17 00:00:00 2001
From: Matei Adriel <rafaeladriel11@gmail.com>
Date: Thu, 25 Jul 2019 14:23:23 +0300
Subject: [PATCH] clear selection when RMB-ing on a gate

---
 .../simulationRenderer/classes/SimulationRenderer.ts       | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/modules/simulationRenderer/classes/SimulationRenderer.ts b/src/modules/simulationRenderer/classes/SimulationRenderer.ts
index 56cc011..baaee2e 100644
--- a/src/modules/simulationRenderer/classes/SimulationRenderer.ts
+++ b/src/modules/simulationRenderer/classes/SimulationRenderer.ts
@@ -33,7 +33,7 @@ import { setToArray } from '../../../common/lang/arrays/helpers/setToArray'
 import { Transform } from '../../../common/math/classes/Transform'
 import { gatesInSelection } from '../helpers/gatesInSelection'
 import { selectionType } from '../types/selectionType'
-import { addIdToSelection } from '../helpers/idIsSelected'
+import { addIdToSelection, idIsSelected } from '../helpers/idIsSelected'
 
 export class SimulationRenderer {
     public mouseDownOutput = new Subject<MouseEventInfo>()
@@ -97,7 +97,10 @@ export class SimulationRenderer {
 
                     this.mouseState |= 1
 
-                    addIdToSelection(this, 'temporary', id)
+                    if (!idIsSelected(this, id)) {
+                        this.clearSelection()
+                        addIdToSelection(this, 'temporary', id)
+                    }
 
                     const gateNode = this.simulation.gates.get(id)