diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index d147aa330..43f2b885e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -222,34 +222,7 @@ namespace Flow.Launcher.Plugin.Explorer if (record.Type is ResultType.Volume) return false; - var screenWithMouseCursor = System.Windows.Forms.Screen.FromPoint(System.Windows.Forms.Cursor.Position); - var xOfScreenCenter = screenWithMouseCursor.WorkingArea.Left + screenWithMouseCursor.WorkingArea.Width / 2; - var yOfScreenCenter = screenWithMouseCursor.WorkingArea.Top + screenWithMouseCursor.WorkingArea.Height / 2; - var showPosition = new System.Drawing.Point(xOfScreenCenter, yOfScreenCenter); - - switch (record.Type) - { - case ResultType.File: - { - var fileInfos = new FileInfo[] - { - new(record.FullPath) - }; - - new Peter.ShellContextMenu().ShowContextMenu(fileInfos, showPosition); - break; - } - case ResultType.Folder: - { - var directoryInfos = new DirectoryInfo[] - { - new(record.FullPath) - }; - - new Peter.ShellContextMenu().ShowContextMenu(directoryInfos, showPosition); - break; - } - } + ResultManager.ShowNativeContextMenu(record.FullPath, record.Type); return false; }, diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 34f80f552..71760d0aa 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -11,6 +11,7 @@ using System.Windows.Input; using Path = System.IO.Path; using System.Windows.Controls; using Flow.Launcher.Plugin.Explorer.Views; +using Peter; namespace Flow.Launcher.Plugin.Explorer.Search { @@ -70,6 +71,27 @@ namespace Flow.Launcher.Plugin.Explorer.Search }; } + internal static void ShowNativeContextMenu(string path, ResultType type) + { + var screenWithMouseCursor = System.Windows.Forms.Screen.FromPoint(System.Windows.Forms.Cursor.Position); + var xOfScreenCenter = screenWithMouseCursor.WorkingArea.Left + screenWithMouseCursor.WorkingArea.Width / 2; + var yOfScreenCenter = screenWithMouseCursor.WorkingArea.Top + screenWithMouseCursor.WorkingArea.Height / 2; + var showPosition = new System.Drawing.Point(xOfScreenCenter, yOfScreenCenter); + + switch (type) + { + case ResultType.File: + var fileInfo = new FileInfo[] { new(path) }; + new ShellContextMenu().ShowContextMenu(fileInfo, showPosition); + break; + + case ResultType.Folder: + var folderInfo = new System.IO.DirectoryInfo[] { new(path) }; + new ShellContextMenu().ShowContextMenu(folderInfo, showPosition); + break; + } + } + internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, int score = 0, bool windowsIndexed = false) { return new Result @@ -82,6 +104,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search CopyText = path, Action = c => { + if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Alt) + { + ShowNativeContextMenu(path, ResultType.Folder); + return false; + } // open folder if (c.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift)) { @@ -218,8 +245,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search IcoPath = folderPath, Score = 500, CopyText = folderPath, - Action = _ => + Action = c => { + if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Alt) + { + ShowNativeContextMenu(folderPath, ResultType.Folder); + return false; + } OpenFolder(folderPath); return true; }, @@ -251,6 +283,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search PreviewPanel = new Lazy(() => new PreviewPanel(Settings, filePath)), Action = c => { + if (c.SpecialKeyState.ToModifierKeys() == ModifierKeys.Alt) + { + ShowNativeContextMenu(filePath, ResultType.File); + return false; + } try { if (c.SpecialKeyState.ToModifierKeys() == (ModifierKeys.Control | ModifierKeys.Shift))