浏览代码

LibGUI: Only reset GlyphMapWidget selection on Escape

and when using unmodified arrows.
thankyouverycool 2 年之前
父节点
当前提交
673afffd5a
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 9 1
      Userland/Libraries/LibGUI/GlyphMapWidget.cpp
  2. 1 0
      Userland/Libraries/LibGUI/GlyphMapWidget.h

+ 9 - 1
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);
     }

+ 1 - 0
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;