瀏覽代碼

fixing selection bug

msDestiny14 4 年之前
父節點
當前提交
9fcfb9b689
共有 3 個文件被更改,包括 8 次插入15 次删除
  1. 1 0
      guiEditor/src/blockTools.ts
  2. 1 5
      guiEditor/src/diagram/guiNode.ts
  3. 6 10
      guiEditor/src/diagram/workbench.tsx

+ 1 - 0
guiEditor/src/blockTools.ts

@@ -39,6 +39,7 @@ export class BlockTools {
         element.width = "150px"
         element.height = "40px";
         element.color = "#FFFFFFFF";
+        element.isPointerBlocker = true;
         return element;
     }
 }

+ 1 - 5
guiEditor/src/diagram/guiNode.ts

@@ -92,10 +92,6 @@ export class GUINode {
     }
 
     public set isSelected(value: boolean) {
-        if (this._isSelected === value) {
-            return;            
-        }
-
         this._isSelected = value;
 
         if (value) {
@@ -145,7 +141,7 @@ export class GUINode {
     public _onMove(evt: BABYLON.Vector2, startPos: BABYLON.Vector2) {
        
         if(!this.clicked) return false;
-
+        console.log("moving");
         let newX = (evt.x - startPos.x) ;// / this._ownerCanvas.zoom;
         let newY = (evt.y - startPos.y) ;// / this._ownerCanvas.zoom;
 

+ 6 - 10
guiEditor/src/diagram/workbench.tsx

@@ -135,11 +135,12 @@ export class WorkbenchComponent extends React.Component<IWorkbenchComponentProps
         super(props);
 
         props.globalState.onSelectionChangedObservable.add(selection => {  
+            console.log(selection);
+            
+            this.selectedGuiNodes.forEach(element => {
+                element.isSelected = false;
+            }); 
             if (!selection) {
-                
-                this.selectedGuiNodes.forEach(element => {
-                    element.isSelected = false;
-                }); 
                 this._selectedGuiNodes = [];
             } 
             else {
@@ -149,14 +150,11 @@ export class WorkbenchComponent extends React.Component<IWorkbenchComponentProps
                             this._selectedGuiNodes.push(selection);
                         }
                     } 
-                    else {                    
+                    else {              
                         this._selectedGuiNodes = [selection];
                     }
                 
                 } 
-                else {
-                    this._selectedGuiNodes = [];
-                }
             }
         });
 
@@ -413,8 +411,6 @@ export class WorkbenchComponent extends React.Component<IWorkbenchComponentProps
         this._rootContainer.releasePointerCapture(evt.pointerId);   
         this._oldY = -1; 
 
-        
-
         if (this._selectionBox) {
            this._selectionBox.parentElement!.removeChild(this._selectionBox);
            this._selectionBox = null;