popup window v3
This commit is contained in:
@@ -2,6 +2,7 @@ using Godot;
|
|||||||
|
|
||||||
namespace SharpIDE.Godot.Features.SlnPicker;
|
namespace SharpIDE.Godot.Features.SlnPicker;
|
||||||
|
|
||||||
|
// This is a bit of a mess intertwined with the optional popup window
|
||||||
public partial class SlnPicker : Control
|
public partial class SlnPicker : Control
|
||||||
{
|
{
|
||||||
private FileDialog _fileDialog = null!;
|
private FileDialog _fileDialog = null!;
|
||||||
@@ -17,16 +18,10 @@ public partial class SlnPicker : Control
|
|||||||
var windowParent = GetParentOrNull<Window>();
|
var windowParent = GetParentOrNull<Window>();
|
||||||
_fileDialog.FileSelected += path =>
|
_fileDialog.FileSelected += path =>
|
||||||
{
|
{
|
||||||
_tcs.SetResult(path);
|
|
||||||
windowParent?.Hide();
|
windowParent?.Hide();
|
||||||
|
_tcs.SetResult(path);
|
||||||
};
|
};
|
||||||
_fileDialog.Canceled += () => _tcs.SetResult(null);
|
windowParent?.CloseRequested += () => _tcs.SetResult(null);
|
||||||
windowParent?.CloseRequested += OnCloseRequested;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnCloseRequested()
|
|
||||||
{
|
|
||||||
_tcs.SetResult(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string?> GetSelectedSolutionPath()
|
public async Task<string?> GetSelectedSolutionPath()
|
||||||
|
|||||||
@@ -36,14 +36,15 @@ public partial class IdeWindow : Control
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var window = GetNode<Window>("Window");
|
var popupWindow = GetNode<Window>("Window");
|
||||||
window.Title = "Open Solution";
|
var windowSize = GetWindow().GetSize();
|
||||||
window.AddChild(_slnPicker);
|
popupWindow.Size = windowSize with { X = windowSize.X / 2, Y = windowSize.Y / 2 };
|
||||||
window.Popup();
|
popupWindow.Title = "Open Solution";
|
||||||
window.CloseRequested += () =>
|
popupWindow.AddChild(_slnPicker);
|
||||||
|
popupWindow.Popup();
|
||||||
|
popupWindow.CloseRequested += () =>
|
||||||
{
|
{
|
||||||
window.Hide();
|
popupWindow.Hide();
|
||||||
//window.QueueFreeChildren();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_ = Task.GodotRun(async () =>
|
_ = Task.GodotRun(async () =>
|
||||||
|
|||||||
Reference in New Issue
Block a user