MCPcopy Create free account
hub / github.com/esengine/esengine / handleNodeClick

Function handleNodeClick

packages/editor-app/src/components/FileTree.tsx:852–897  ·  view source on GitHub ↗
(node: TreeNode, e: React.MouseEvent)

Source from the content-addressed store, hash-verified

850 };
851
852 const handleNodeClick = (node: TreeNode, e: React.MouseEvent) => {
853 if (node.type === 'folder') {
854 setInternalSelectedPath(node.path);
855 onSelectFile?.(node.path);
856 toggleNode(node.path);
857 } else {
858 setInternalSelectedPath(node.path);
859
860 // Support multi-select with Ctrl/Cmd or Shift
861 if (onSelectFiles) {
862 if (e.shiftKey && lastSelectedFilePath) {
863 // Range select with Shift
864 const treeToUse = searchQuery ? filteredTree : tree;
865 const visiblePaths = getVisibleFilePaths(treeToUse);
866 const lastIndex = visiblePaths.indexOf(lastSelectedFilePath);
867 const currentIndex = visiblePaths.indexOf(node.path);
868 if (lastIndex !== -1 && currentIndex !== -1) {
869 const start = Math.min(lastIndex, currentIndex);
870 const end = Math.max(lastIndex, currentIndex);
871 const rangePaths = visiblePaths.slice(start, end + 1);
872 onSelectFiles(rangePaths, { ctrlKey: false, shiftKey: true });
873 } else {
874 onSelectFiles([node.path], { ctrlKey: false, shiftKey: false });
875 setLastSelectedFilePath(node.path);
876 }
877 } else {
878 onSelectFiles([node.path], { ctrlKey: e.ctrlKey || e.metaKey, shiftKey: false });
879 setLastSelectedFilePath(node.path);
880 }
881 } else {
882 setLastSelectedFilePath(node.path);
883 }
884
885 const extension = node.name.includes('.') ? node.name.split('.').pop() : undefined;
886 messageHub?.publish('asset-file:selected', {
887 fileInfo: {
888 name: node.name,
889 path: node.path,
890 extension,
891 size: node.size,
892 modified: node.modified,
893 isDirectory: false
894 }
895 });
896 }
897 };
898
899 const handleNodeDoubleClick = async (node: TreeNode) => {
900 if (node.type === 'file') {

Callers 1

renderNodeFunction · 0.85

Calls 6

toggleNodeFunction · 0.85
getVisibleFilePathsFunction · 0.85
popMethod · 0.80
publishMethod · 0.65
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected