-
Notifications
You must be signed in to change notification settings - Fork 385
Added deselect on esc shortcut when selection tool active #2205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| // | ||
|
Check failure on line 1 in Pinta.Core/Actions/EditActions.cs
|
||
| // EditActions.cs | ||
|
Check failure on line 2 in Pinta.Core/Actions/EditActions.cs
|
||
| // | ||
|
Check failure on line 3 in Pinta.Core/Actions/EditActions.cs
|
||
| // Author: | ||
|
Check failure on line 4 in Pinta.Core/Actions/EditActions.cs
|
||
| // Jonathan Pobst <monkey@jpobst.com> | ||
|
Check failure on line 5 in Pinta.Core/Actions/EditActions.cs
|
||
| // | ||
|
Check failure on line 6 in Pinta.Core/Actions/EditActions.cs
|
||
| // Copyright (c) 2010 Jonathan Pobst | ||
|
Check failure on line 7 in Pinta.Core/Actions/EditActions.cs
|
||
| // | ||
|
Check failure on line 8 in Pinta.Core/Actions/EditActions.cs
|
||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
Check failure on line 9 in Pinta.Core/Actions/EditActions.cs
|
||
| // of this software and associated documentation files (the "Software"), to deal | ||
|
Check failure on line 10 in Pinta.Core/Actions/EditActions.cs
|
||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
|
|
@@ -47,6 +47,7 @@ | |
| 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 @@ | |
| 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 @@ | |
| Resources.Icons.EditSelectionNone, | ||
| shortcuts: ["<Primary><Shift>A", "<Ctrl>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 @@ | |
|
|
||
| SelectAll, | ||
| Deselect, | ||
| DeselectSelection, | ||
|
|
||
| EraseSelection, | ||
| FillSelection, | ||
|
|
@@ -270,6 +281,7 @@ | |
| public void RegisterHandlers () | ||
| { | ||
| Deselect.Activated += HandlePintaCoreActionsEditDeselectActivated; | ||
| DeselectSelection.Activated += HandlePintaCoreActionsEditDeselectSelectionActivated; | ||
| EraseSelection.Activated += HandlePintaCoreActionsEditEraseSelectionActivated; | ||
| SelectAll.Activated += HandlePintaCoreActionsEditSelectAllActivated; | ||
| FillSelection.Activated += HandlePintaCoreActionsEditFillSelectionActivated; | ||
|
|
@@ -391,6 +403,16 @@ | |
| doc.Workspace.Invalidate (); | ||
| } | ||
|
|
||
| private void HandlePintaCoreActionsEditDeselectSelectionActivated (object sender, EventArgs e) | ||
| { | ||
|
|
||
| if (!selection_tools.Contains (tools.CurrentTool?.ToString ())) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an |
||
| return; | ||
| } | ||
|
|
||
| HandlePintaCoreActionsEditDeselectActivated (sender,e); | ||
| } | ||
|
|
||
| private void HandlerPintaCoreActionsEditCopyActivated (object sender, EventArgs e) | ||
| { | ||
| Document doc = workspace.ActiveDocument; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving this command the same identifier as the other deselect command will probably cause some issues - e.g. on macOS this seems to cause the menu item to not show its shortcut.
However, I think it'd be worth trying to just merge this with the other command and just add
Escapeas an alternative shortcut which works while in any tool (matching Paint.NET behaviour). The only thing to test would be to verify that the text tool can still handle Escape to finish editing the text while a selection is active, then pressing Escape again would clear the selection