file right click menu

This commit is contained in:
Matt Parker
2025-10-10 18:17:59 +10:00
parent 6474150b07
commit 5f2680f33e
2 changed files with 39 additions and 1 deletions

View File

@@ -37,7 +37,44 @@ public partial class SolutionExplorerPanel : MarginContainer
if (sharpIdeFileContainer is null) return;
var sharpIdeFile = sharpIdeFileContainer.Item;
Guard.Against.Null(sharpIdeFile, nameof(sharpIdeFile));
GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(sharpIdeFile, null);
if (mouseButtonIndex is (int)MouseButtonMask.Left)
{
GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(sharpIdeFile, null);
}
else if (mouseButtonIndex is (int)MouseButtonMask.Right)
{
var menu = new PopupMenu();
AddChild(menu);
menu.AddItem("Open", 0);
menu.AddItem("Reveal in File Explorer", 1);
menu.AddSeparator();
menu.AddItem("Copy Full Path", 2);
menu.PopupHide += () =>
{
GD.Print("QueueFree menu");
menu.QueueFree();
};
menu.IdPressed += id =>
{
if (id is 0)
{
GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(sharpIdeFile, null);
}
else if (id is 1)
{
OS.ShellOpen(Path.GetDirectoryName(sharpIdeFile.Path)!);
}
else if (id is 2)
{
DisplayServer.ClipboardSet(sharpIdeFile.Path);
}
};
var globalMousePosition = GetGlobalMousePosition();
menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y);
menu.Popup();
}
}
private async Task OnFileExternallySelected(SharpIdeFile file, SharpIdeFileLinePosition? fileLinePosition)

View File

@@ -26,3 +26,4 @@ theme_override_colors/font_color = Color(0.830335, 0.830335, 0.830335, 1)
theme_override_constants/v_separation = 1
theme_override_constants/inner_item_margin_left = 2
theme_override_constants/draw_guides = 0
allow_rmb_select = true