Step 88: drag-and-drop open

This commit is contained in:
Bill
2026-02-09 09:38:57 -07:00
parent a1efe93ba3
commit 23e3758cca
5 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#pragma once
// Step 88: Drag-and-drop handler
#include <string>
#include <functional>
#include <filesystem>
class DragDropHandler {
public:
using FileCallback = std::function<void(const std::string&)>;
using FolderCallback = std::function<void(const std::string&)>;
static void handleDrop(const std::string& path,
const FileCallback& onFile,
const FolderCallback& onFolder) {
if (path.empty()) return;
std::filesystem::path p(path);
if (std::filesystem::is_directory(p)) {
if (onFolder) onFolder(path);
} else {
if (onFile) onFile(path);
}
}
};