Browse Source

Delete Objects in Scene Explorer with the Delete Key (#8675)

* being able to delete objects with the delete key on scene explorer.

* fixing bug on playground

* linting

Co-authored-by: Pamela Wolf <pamela.wolf@digipen.edu>
Pamela W 5 years ago
parent
commit
d387334713
1 changed files with 3 additions and 1 deletions
  1. 3 1
      inspector/src/components/sceneExplorer/sceneExplorerComponent.tsx

+ 3 - 1
inspector/src/components/sceneExplorer/sceneExplorerComponent.tsx

@@ -215,6 +215,8 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
             }
             keyEvent.preventDefault();
             return;
+        } else if (keyEvent.keyCode === 46) { // delete
+            this.state.selectedEntity.dispose();
         }
 
         if (!search) {
@@ -451,7 +453,7 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
     render() {
         if (this.props.popupMode) {
             return (
-                <div id="sceneExplorer">
+                <div id="sceneExplorer" tabIndex={0} onKeyDown={(keyEvent) => this.processKeys(keyEvent)}>
                     {
                         !this.props.noHeader &&
                         <HeaderComponent title="SCENE EXPLORER" noClose={this.props.noClose} noExpand={this.props.noExpand} noCommands={this.props.noCommands} onClose={() => this.onClose()} onPopup={() => this.onPopup()} />