Cancel active tool with Escape

This commit is contained in:
Isaiah Odhner 2023-04-26 00:17:18 -04:00
parent c6967c69f5
commit 63c9a3ea11
2 changed files with 5 additions and 1 deletions

View File

@ -128,7 +128,7 @@ cat file.ans
- Pressing Delete while using the Text tool deletes the whole text box. Similarly, Ctrl+A selects the canvas instead of the text in the text box.
- Selection box border is inside instead of outside (and lacks dashes). For the text box, I hid the border because it was too visually confusing, but it should also have an outer border.
- Tools can't be cancelled with Escape or by pressing both mouse buttons.
- Pick Color can't be cancelled, since it samples the color continuously. No tools can be cancelled by pressing both mouse buttons, only with Escape.
- Help > Help Topics isn't very helpful.
- Due to limitations of the terminal, shortcuts using Shift or Alt might not work.
- Menus are not keyboard navigable.

View File

@ -1154,6 +1154,7 @@ class PaintApp(App[None]):
Binding("ctrl+pagedown", "large_size", _("Large Size")),
# action_toggle_dark is built in to App
Binding("ctrl+d", "toggle_dark", _("Toggle Dark Mode")),
Binding("escape", "cancel", _("Cancel")),
Binding("f1", "help_topics", _("Help Topics")),
# dev helper
# f5 would be more traditional, but I need something not bound to anything
@ -1459,6 +1460,9 @@ class PaintApp(App[None]):
self.tool_points = []
def action_cancel(self) -> None:
self.stop_action_in_progress()
def stop_action_in_progress(self) -> None:
"""Finalizes the selection, or cancels other tools."""
self.cancel_preview()