Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix key navigation in scene explorer #14450

Merged
merged 2 commits into from Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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