summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-12-17 13:12:15 -0500
committerAndreas Kling <kling@serenityos.org>2022-12-20 10:22:27 +0100
commit673afffd5ad1a0101502cbfdaffed3ad79ca4456 (patch)
tree0a4b50c24f24283b66bc65eaa9df1fe4fc5af279
parent4c81fbc8c42c7f1d7c7a9083d8d76f07102e5378 (diff)
downloadserenity-673afffd5ad1a0101502cbfdaffed3ad79ca4456.zip
LibGUI: Only reset GlyphMapWidget selection on Escape
and when using unmodified arrows.
-rw-r--r--Userland/Libraries/LibGUI/GlyphMapWidget.cpp10
-rw-r--r--Userland/Libraries/LibGUI/GlyphMapWidget.h1
2 files changed, 10 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
index 566ecbc8f6..381219bdea 100644
--- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
+++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
@@ -263,7 +263,15 @@ void GlyphMapWidget::keydown_event(KeyEvent& event)
return;
}
- if (!event.ctrl() && !event.shift() && event.key() != KeyCode::Key_Delete) {
+ if (event.key() == KeyCode::Key_Escape) {
+ m_selection.set_size(1);
+ m_selection.set_start(m_active_glyph);
+ if (on_escape_pressed)
+ on_escape_pressed();
+ return;
+ }
+
+ if (!event.modifiers() && event.is_arrow_key()) {
m_selection.set_size(1);
m_selection.set_start(m_active_glyph);
}
diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.h b/Userland/Libraries/LibGUI/GlyphMapWidget.h
index 4dd1134765..0c2746c731 100644
--- a/Userland/Libraries/LibGUI/GlyphMapWidget.h
+++ b/Userland/Libraries/LibGUI/GlyphMapWidget.h
@@ -73,6 +73,7 @@ public:
int rows() const { return m_rows; }
int columns() const { return m_columns; }
+ Function<void()> on_escape_pressed;
Function<void(int)> on_active_glyph_changed;
Function<void(int)> on_glyph_double_clicked;
Function<void(ContextMenuEvent&)> on_context_menu_request;