Skip to content

Commit

Permalink
Merge pull request #14450 from sebavan/InspectorNavigation
Browse files Browse the repository at this point in the history
Fix key navigation in scene explorer
  • Loading branch information
sebavan committed Oct 20, 2023
2 parents 57f84af + f22f51c commit 539283a
Showing 1 changed file with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
return false;
}

processKeys(keyEvent: React.KeyboardEvent<HTMLDivElement>) {
processKeys(keyEvent: React.KeyboardEvent<HTMLDivElement>, allNodes: any[]) {
if (!this.state.selectedEntity) {
return;
}
Expand Down Expand Up @@ -253,9 +253,9 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
keyEvent.preventDefault();

const data = {};
if (!this.findSiblings(null, scene.rootNodes, this.state.selectedEntity, goNext, data)) {
if (!this.findSiblings(null, scene.materials, this.state.selectedEntity, goNext, data)) {
this.findSiblings(null, scene.textures, this.state.selectedEntity, goNext, data);
for (const nodeGroup of allNodes) {
if (this.findSiblings(null, nodeGroup, this.state.selectedEntity, goNext, data)) {
break;
}
}
}
Expand Down Expand Up @@ -451,7 +451,7 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
return useDefaults ? [...defaultMenuItems, ...customMenuItems] : customMenuItems;
}

renderContent() {
renderContent(allNodes: any[]) {
const scene = this.state.scene;

if (!scene) {
Expand Down Expand Up @@ -507,6 +507,23 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
}
}

allNodes.push(
rootNodes,
scene.skeletons,
materials,
textures,
postProcesses,
pipelines,
scene.effectLayers,
scene.particleSystems,
scene.spriteManagers,
guiElements,
scene.animationGroups
);
if (scene.mainSoundTrack) {
allNodes.push(scene.mainSoundTrack.soundCollection);
}

return (
<div id="tree" onContextMenu={(e) => e.preventDefault()}>
<SceneExplorerFilterComponent onFilter={(filter) => this.filterContent(filter)} />
Expand Down Expand Up @@ -682,9 +699,11 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
}

render() {
const allNodes: any[] = [];

if (this.props.popupMode) {
return (
<div id="sceneExplorer" tabIndex={0} onKeyDown={(keyEvent) => this.processKeys(keyEvent)}>
<div id="sceneExplorer" tabIndex={0} onKeyDown={(keyEvent) => this.processKeys(keyEvent, allNodes)}>
{!this.props.noHeader && (
<HeaderComponent
title="SCENE EXPLORER"
Expand All @@ -695,7 +714,7 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
onPopup={() => this.onPopup()}
/>
)}
{this.renderContent()}
{this.renderContent(allNodes)}
</div>
);
}
Expand All @@ -722,7 +741,7 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
maxWidth={600}
minHeight="100%"
enable={{ top: false, right: true, bottom: false, left: false, topRight: false, bottomRight: false, bottomLeft: false, topLeft: false }}
onKeyDown={(keyEvent) => this.processKeys(keyEvent)}
onKeyDown={(keyEvent) => this.processKeys(keyEvent, allNodes)}
>
{!this.props.noHeader && (
<HeaderComponent
Expand All @@ -734,7 +753,7 @@ export class SceneExplorerComponent extends React.Component<ISceneExplorerCompon
onPopup={() => this.onPopup()}
/>
)}
{this.renderContent()}
{this.renderContent(allNodes)}
</Resizable>
);
}
Expand Down

0 comments on commit 539283a

Please sign in to comment.