From 78912c155215a05faf5c37252b3f8181ffa389ba Mon Sep 17 00:00:00 2001 From: Glorou Date: Sun, 8 Feb 2026 21:56:48 -0500 Subject: [PATCH 1/5] Init --- Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs | 1 + Dalamud/Interface/ImGuiFileDialog/FileDialog.cs | 2 ++ .../Interface/ImGuiFileDialog/FileDialogManager.cs | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs index ef886e957..484b883ee 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs @@ -648,6 +648,7 @@ public partial class FileDialog private void AddFileNameInSelection(string name, bool setLastSelection) { this.selectedFileNames.Add(name); + this.SelectionChanged(this, this.GetFilePathName()); if (this.selectedFileNames.Count == 1) { this.fileNameBuffer = name; diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs index e33fc2fc4..b9ac634ab 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs @@ -97,6 +97,8 @@ public partial class FileDialog this.SetupSideBar(); } + public event EventHandler? SelectionChanged; + /// /// Shows the dialog. /// diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs index ee12e7424..eca65cd72 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using Dalamud.Bindings.ImGui; +using FFXIVClientStructs; + namespace Dalamud.Interface.ImGuiFileDialog; /// @@ -25,11 +27,13 @@ public class FileDialogManager #pragma warning restore SA1401 #pragma warning restore SA1201 + public event EventHandler? SelectionChanged; private FileDialog? dialog; private Action? callback; private Action>? multiCallback; private string savedPath = "."; + /// /// Create a dialog which selects an already existing folder. /// @@ -175,6 +179,13 @@ public class FileDialogManager this.multiCallback = null; } + public string? GetCurrentPath() + { + return this.dialog?.GetCurrentPath(); + } + + private void OnSelectionChange(object sender, string path) => this.SelectionChanged(sender, path); + private void SetDialog( string id, string title, @@ -200,9 +211,11 @@ public class FileDialogManager if (this.dialog is not null) { this.dialog.SortOrderChanged -= this.OnSortOrderChange; + this.dialog.SelectionChanged -= this.OnSelectionChange; } this.dialog = new FileDialog(id, title, filters, path, defaultFileName, defaultExtension, selectionCountMax, isModal, flags); + if (this.GetDefaultSortOrder is not null) { try @@ -217,6 +230,7 @@ public class FileDialogManager } this.dialog.SortOrderChanged += this.OnSortOrderChange; + this.dialog.SelectionChanged += this.OnSelectionChange; this.dialog.WindowFlags |= this.AddedWindowFlags; foreach (var (name, location, icon, position) in this.CustomSideBarItems) this.dialog.SetQuickAccess(name, location, icon, position); From 332d0d0cf5bc143401f6a0032d54bb0ea0d7390c Mon Sep 17 00:00:00 2001 From: Glorou Date: Mon, 9 Feb 2026 10:38:14 -0500 Subject: [PATCH 2/5] Tweaked --- Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs | 3 +-- Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs index 484b883ee..289203d59 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs @@ -648,7 +648,6 @@ public partial class FileDialog private void AddFileNameInSelection(string name, bool setLastSelection) { this.selectedFileNames.Add(name); - this.SelectionChanged(this, this.GetFilePathName()); if (this.selectedFileNames.Count == 1) { this.fileNameBuffer = name; @@ -657,7 +656,7 @@ public partial class FileDialog { this.fileNameBuffer = $"{this.selectedFileNames.Count} files Selected"; } - + this.SelectionChanged(this, this.GetFilePathName()); if (setLastSelection) { this.lastSelectedFileName = name; diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs index eca65cd72..5e0a03b66 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs @@ -27,12 +27,13 @@ public class FileDialogManager #pragma warning restore SA1401 #pragma warning restore SA1201 - public event EventHandler? SelectionChanged; + private FileDialog? dialog; private Action? callback; private Action>? multiCallback; private string savedPath = "."; + public event EventHandler? SelectionChanged; /// /// Create a dialog which selects an already existing folder. @@ -184,7 +185,7 @@ public class FileDialogManager return this.dialog?.GetCurrentPath(); } - private void OnSelectionChange(object sender, string path) => this.SelectionChanged(sender, path); + private void OnSelectionChange(object sender, string path) => this.SelectionChanged?.Invoke(sender, path); private void SetDialog( string id, From 256ab9dc9c11d0c73a9449dbf8994ed7a75f89e9 Mon Sep 17 00:00:00 2001 From: Glorou Date: Mon, 9 Feb 2026 10:38:32 -0500 Subject: [PATCH 3/5] add whitespace --- Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs index 289203d59..b1fc6e049 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs @@ -656,6 +656,7 @@ public partial class FileDialog { this.fileNameBuffer = $"{this.selectedFileNames.Count} files Selected"; } + this.SelectionChanged(this, this.GetFilePathName()); if (setLastSelection) { From 8285aa1014777285e418a49c79a9547c90133840 Mon Sep 17 00:00:00 2001 From: Glorou <93338547+Glorou@users.noreply.github.com> Date: Mon, 9 Feb 2026 10:50:46 -0500 Subject: [PATCH 4/5] Clean up FileDialogManager by removing unused code Removed unused GetCurrentPath method and unnecessary using directives. --- Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs index 5e0a03b66..8cf0baa2c 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using Dalamud.Bindings.ImGui; -using FFXIVClientStructs; - namespace Dalamud.Interface.ImGuiFileDialog; /// @@ -27,7 +25,6 @@ public class FileDialogManager #pragma warning restore SA1401 #pragma warning restore SA1201 - private FileDialog? dialog; private Action? callback; private Action>? multiCallback; @@ -180,11 +177,6 @@ public class FileDialogManager this.multiCallback = null; } - public string? GetCurrentPath() - { - return this.dialog?.GetCurrentPath(); - } - private void OnSelectionChange(object sender, string path) => this.SelectionChanged?.Invoke(sender, path); private void SetDialog( From e2297661f30c852932aee1b000002aee4bd91e0a Mon Sep 17 00:00:00 2001 From: Glorou Date: Mon, 9 Feb 2026 11:17:11 -0500 Subject: [PATCH 5/5] Added doc --- Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs index 8cf0baa2c..7332cd735 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs @@ -30,6 +30,10 @@ public class FileDialogManager private Action>? multiCallback; private string savedPath = "."; + /// + /// Event fires when a new file is selected by the user + /// + /// Returns the path of the file as a string public event EventHandler? SelectionChanged; /// @@ -208,7 +212,6 @@ public class FileDialogManager } this.dialog = new FileDialog(id, title, filters, path, defaultFileName, defaultExtension, selectionCountMax, isModal, flags); - if (this.GetDefaultSortOrder is not null) { try