popup window v3

This commit is contained in:
Matt Parker
2025-09-30 19:04:03 +10:00
parent aee8ae4cf6
commit 4256db8df4
2 changed files with 11 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ using Godot;
namespace SharpIDE.Godot.Features.SlnPicker;
// This is a bit of a mess intertwined with the optional popup window
public partial class SlnPicker : Control
{
private FileDialog _fileDialog = null!;
@@ -17,16 +18,10 @@ public partial class SlnPicker : Control
var windowParent = GetParentOrNull<Window>();
_fileDialog.FileSelected += path =>
{
_tcs.SetResult(path);
windowParent?.Hide();
_tcs.SetResult(path);
};
_fileDialog.Canceled += () => _tcs.SetResult(null);
windowParent?.CloseRequested += OnCloseRequested;
}
private void OnCloseRequested()
{
_tcs.SetResult(null);
windowParent?.CloseRequested += () => _tcs.SetResult(null);
}
public async Task<string?> GetSelectedSolutionPath()

View File

@@ -36,14 +36,15 @@ public partial class IdeWindow : Control
}
else
{
var window = GetNode<Window>("Window");
window.Title = "Open Solution";
window.AddChild(_slnPicker);
window.Popup();
window.CloseRequested += () =>
var popupWindow = GetNode<Window>("Window");
var windowSize = GetWindow().GetSize();
popupWindow.Size = windowSize with { X = windowSize.X / 2, Y = windowSize.Y / 2 };
popupWindow.Title = "Open Solution";
popupWindow.AddChild(_slnPicker);
popupWindow.Popup();
popupWindow.CloseRequested += () =>
{
window.Hide();
//window.QueueFreeChildren();
popupWindow.Hide();
};
}
_ = Task.GodotRun(async () =>