A C++ file dialog using Dear ImGui.
Add L2DFileDialog.h
to your C++ project and include it where you use ImGui. Then, set FileDialog::fileDialogOpen
to true
to set the open state. Finally, in your update
method, check if FileDialog::fileDialogOpen == true
and if so, call FileDialog::ShowFileDialog
, passing in a char
array as a buffer to store the chosen file/folder path.
- New folder
- Delete folder
- Sort by:
- File
- Size
- Type
- Last modified date
You can see L2dFileDialog/src/main.cpp
for a full example. Here is a very minimal sample:
...
static char* file_dialog_buffer = nullptr;
static char path[500] = "";
ImGui::TextUnformatted("Path: ");
ImGui::InputText("##path", path, sizeof(path));
ImGui::SameLine();
if (ImGui::Button("Browse##path")) {
file_dialog_buffer = path;
FileDialog::file_dialog_open = true;
FileDialog::file_dialog_open_type = FileDialog::FileDialogType::SelectFolder;
}
if (FileDialog::file_dialog_open) {
FileDialog::ShowFileDialog(&FileDialog::file_dialog_open, file_dialog_buffer, sizeof(file_dialog_buffer), FileDialog::file_dialog_open_type);
}
...
This project is under the Apache License.