Selaa lähdekoodia

Merge pull request #1082 from LumaDigital/GF_SearchBarFix

Search Bar Update
JoshEngebretson 9 vuotta sitten
vanhempi
sitoutus
a232ba695a

+ 13 - 15
Script/AtomicEditor/ui/frames/HierarchyFrame.ts

@@ -160,21 +160,6 @@ class HierarchyFrame extends Atomic.UIWidget {
 
 
         });
         });
 
 
-        // Activates search while user is typing in search widget
-        this.searchEdit.subscribeToEvent(this.searchEdit, "WidgetEvent", (data) => {
-            if (!ToolCore.toolSystem.project) return;
-
-            if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
-                this.search = true;
-                this.populate();
-
-                if (this.searchEdit.text == "" && this.selectedNode) {
-                        this.hierList.selectItemByID(this.selectedNode.id.toString(), true);    //maintains selected item after search is cancelled
-                }
-
-            }
-        });
-
     }
     }
 
 
     handleSceneEditNodeAdded(ev: Editor.SceneEditNodeAddedEvent) {
     handleSceneEditNodeAdded(ev: Editor.SceneEditNodeAddedEvent) {
@@ -421,8 +406,21 @@ class HierarchyFrame extends Atomic.UIWidget {
 
 
     handleWidgetEvent(data: Atomic.UIWidgetEvent): boolean {
     handleWidgetEvent(data: Atomic.UIWidgetEvent): boolean {
 
 
+        if (!this.scene) return;
+
         if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
         if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
 
 
+            // activates search while user is typing in search widget
+            if (data.target == this.searchEdit) {
+
+                this.search = true;
+                this.populate();
+
+                if (this.searchEdit.text == "" && this.selectedNode) {
+                        this.hierList.selectItemByID(this.selectedNode.id.toString(), true);    //maintains selected item after search is cancelled
+                }
+            }
+
             // node deletion
             // node deletion
             if (data.key == Atomic.KEY_DELETE || data.key == Atomic.KEY_BACKSPACE) {
             if (data.key == Atomic.KEY_DELETE || data.key == Atomic.KEY_BACKSPACE) {
                 this.sceneEditor.selection.delete();
                 this.sceneEditor.selection.delete();

+ 14 - 11
Script/AtomicEditor/ui/frames/ProjectFrame.ts

@@ -88,17 +88,6 @@ class ProjectFrame extends ScriptWidget {
 
 
         });
         });
 
 
-        // Activates search while user is typing in search widget
-        this.searchEdit.subscribeToEvent(this.searchEdit, "WidgetEvent", (data) => {
-
-            if (!ToolCore.toolSystem.project) return;
-
-            if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
-                this.search = true;
-                this.refreshContent(this.currentFolder);
-            }
-        });
-
     }
     }
 
 
     handleAssetRenamed(ev: ToolCore.AssetRenamedEvent) {
     handleAssetRenamed(ev: ToolCore.AssetRenamedEvent) {
@@ -174,6 +163,20 @@ class ProjectFrame extends ScriptWidget {
 
 
     handleWidgetEvent(data: Atomic.UIWidgetEvent): boolean {
     handleWidgetEvent(data: Atomic.UIWidgetEvent): boolean {
 
 
+        if (!ToolCore.toolSystem.project) return;
+
+        if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
+
+            // Activates search while user is typing in search widget
+            if (data.target == this.searchEdit) {
+
+                if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
+                    this.search = true;
+                    this.refreshContent(this.currentFolder);
+                }
+            }
+        }
+
         if (data.type == Atomic.UI_EVENT_TYPE_RIGHT_POINTER_UP) {
         if (data.type == Atomic.UI_EVENT_TYPE_RIGHT_POINTER_UP) {
 
 
             var id = data.target.id;
             var id = data.target.id;

+ 8 - 8
Script/AtomicEditor/ui/modal/ResourceSelection.ts

@@ -52,14 +52,6 @@ class ResourceSelection extends ModalWindow {
         this.setSize(800, 600);
         this.setSize(800, 600);
         this.center();
         this.center();
 
 
-        //Activates the search as the user types
-        this.searchEdit.subscribeToEvent(this.searchEdit, "WidgetEvent", (data) => {
-
-            if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
-                this.populate(this.importerType, this.resourceType, true);
-            }
-        });
-
     }
     }
 
 
     //adjusted to delete current folderlist and replace with search list if search is activated
     //adjusted to delete current folderlist and replace with search list if search is activated
@@ -129,6 +121,14 @@ class ResourceSelection extends ModalWindow {
             }
             }
         }
         }
 
 
+        if (ev.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
+
+            //Activates the search as the user types
+            if (ev.target == this.searchEdit)
+                this.populate(this.importerType, this.resourceType, true);
+
+        }
+
         if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
         if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
             var id = ev.target.id;
             var id = ev.target.id;