diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index cde997cf..ea6e43de 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -40,7 +40,8 @@ class MyEntityScript is ScriptableEntity { #include -namespace Nuake { +namespace Nuake +{ // TODO: add filetree in same panel void FileSystemUI::Draw() @@ -170,11 +171,12 @@ namespace Nuake { ImGui::OpenPopup(hoverMenuId.c_str()); m_hasClickedOnFile = true; } + if (ImGui::BeginPopup(hoverMenuId.c_str())) { if (ImGui::MenuItem("Delete")) { - if(FileSystem::RemoveFile(file->GetAbsolutePath().c_str()) != 0) + if(FileSystem::RemoveFile(file->GetAbsolutePath()) != 0) { Logger::Log("Failed to remove file: " + file->GetAbsolutePath(), CRITICAL); } @@ -202,7 +204,10 @@ namespace Nuake { void FileSystemUI::DrawContextMenu() { if (!m_hasClickedOnFile && ImGui::IsMouseReleased(1) && ImGui::IsWindowHovered()) + { ImGui::OpenPopup("window_hover_menu"); + } + if (ImGui::BeginPopup("window_hover_menu")) { if (ImGui::MenuItem("New folder")) @@ -401,6 +406,7 @@ namespace Nuake { DrawContextMenu(); m_hasClickedOnFile = false; + ImGui::EndTable(); } diff --git a/Nuake/src/Core/FileSystem.cpp b/Nuake/src/Core/FileSystem.cpp index 0c9de64d..1376a051 100644 --- a/Nuake/src/Core/FileSystem.cpp +++ b/Nuake/src/Core/FileSystem.cpp @@ -166,9 +166,9 @@ namespace Nuake fileWriter.close(); } - int FileSystem::RemoveFile(char const* path) + int FileSystem::RemoveFile(const std::string& path) { - return std::remove(path); + return std::remove(path.c_str()); } Ref FileSystem::GetFileTree() diff --git a/Nuake/src/Core/FileSystem.h b/Nuake/src/Core/FileSystem.h index e24efaac..f0f8ecf1 100644 --- a/Nuake/src/Core/FileSystem.h +++ b/Nuake/src/Core/FileSystem.h @@ -43,7 +43,7 @@ namespace Nuake static bool BeginWriteFile(const std::string path); static bool WriteLine(const std::string line); static void EndWriteFile(); - static int RemoveFile(char const* path); + static int RemoveFile(const std::string& path); }; class File