From dc5402f61e4bbfa7af70a1cdb9d4b0e75d33626b Mon Sep 17 00:00:00 2001 From: Timothy Slater Date: Wed, 16 Nov 2022 08:51:14 -0600 Subject: [PATCH] PixelPaint: Clear selection with escape key regardless of active tool This makes ImageEditor responsible for clearing the active selection when the escape key is pressed. If the active tool didn't act on the Escape key (like some selection tools use this to indicate cancelling of making a new selection), then ImageEditor will check for an active selection and clear it. --- Userland/Applications/PixelPaint/ImageEditor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 240e8efadde..3e56f97bc99 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -423,6 +423,11 @@ void ImageEditor::keydown_event(GUI::KeyEvent& event) if (m_active_tool && m_active_tool->on_keydown(event)) return; + if (event.key() == Key_Escape && !m_image->selection().is_empty()) { + m_image->selection().clear(); + return; + } + event.ignore(); }