Преглед изворни кода

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;
         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_size(1);
         m_selection.set_start(m_active_glyph);
         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 rows() const { return m_rows; }
     int columns() const { return m_columns; }
     int columns() const { return m_columns; }
 
 
+    Function<void()> on_escape_pressed;
     Function<void(int)> on_active_glyph_changed;
     Function<void(int)> on_active_glyph_changed;
     Function<void(int)> on_glyph_double_clicked;
     Function<void(int)> on_glyph_double_clicked;
     Function<void(ContextMenuEvent&)> on_context_menu_request;
     Function<void(ContextMenuEvent&)> on_context_menu_request;