diff --git a/Pinta.Core/Actions/EditActions.cs b/Pinta.Core/Actions/EditActions.cs index 45508e7f1e..f3987367e1 100644 --- a/Pinta.Core/Actions/EditActions.cs +++ b/Pinta.Core/Actions/EditActions.cs @@ -47,6 +47,7 @@ public sealed class EditActions public Command OffsetSelection { get; } public Command SelectAll { get; } public Command Deselect { get; } + public Command DeselectSelection { get; } public Command LoadPalette { get; } public Command SavePalette { get; } public Command ResetPalette { get; } @@ -55,6 +56,8 @@ public sealed class EditActions private Gio.File? last_palette_dir = null; private Document? active_document = null; + private static readonly string[] selection_tools = ["Pinta.Tools.EllipseSelectTool", "Pinta.Tools.RectangleSelectTool", "Pinta.Tools.LassoSelectTool"]; + private readonly ChromeManager chrome; private readonly PaletteFormatManager palette_formats; private readonly PaletteManager palette; @@ -166,6 +169,13 @@ public EditActions ( Resources.Icons.EditSelectionNone, shortcuts: ["A", "D"]); + DeselectSelection = new Command ( + "deselect", + Translations.GetString ("Deselect All"), + null, + Resources.Icons.EditSelectionNone, + shortcuts: ["Escape"]); + LoadPalette = new Command ( "loadpalette", Translations.GetString ("Open..."), @@ -250,6 +260,7 @@ public void RegisterActions (Gtk.Application app, Gio.Menu menu) SelectAll, Deselect, + DeselectSelection, EraseSelection, FillSelection, @@ -270,6 +281,7 @@ public void CreateHistoryWindowToolBar (Gtk.Box toolbar) public void RegisterHandlers () { Deselect.Activated += HandlePintaCoreActionsEditDeselectActivated; + DeselectSelection.Activated += HandlePintaCoreActionsEditDeselectSelectionActivated; EraseSelection.Activated += HandlePintaCoreActionsEditEraseSelectionActivated; SelectAll.Activated += HandlePintaCoreActionsEditSelectAllActivated; FillSelection.Activated += HandlePintaCoreActionsEditFillSelectionActivated; @@ -391,6 +403,16 @@ private void HandlePintaCoreActionsEditDeselectActivated (object sender, EventAr doc.Workspace.Invalidate (); } + private void HandlePintaCoreActionsEditDeselectSelectionActivated (object sender, EventArgs e) + { + + if (!selection_tools.Contains (tools.CurrentTool?.ToString ())) { + return; + } + + HandlePintaCoreActionsEditDeselectActivated (sender,e); + } + private void HandlerPintaCoreActionsEditCopyActivated (object sender, EventArgs e) { Document doc = workspace.ActiveDocument;