From f922ffb03212678c0d880123c210942d3e5604f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Tue, 28 Sep 2021 17:17:36 +0200 Subject: [PATCH] LibGUI: Make ComboBox text editor release focus when Escape is pressed --- Userland/Libraries/LibGUI/ComboBox.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index e84846b523..ff221dccf2 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -7,10 +7,12 @@ #include #include #include +#include #include #include #include #include +#include #include REGISTER_WIDGET(GUI, ComboBox) @@ -36,6 +38,16 @@ private: if (on_mousewheel) on_mousewheel(event.wheel_delta()); } + + virtual void keydown_event(KeyEvent& event) override + { + if (event.key() == Key_Escape) { + if (is_focused()) + set_focus(false); + event.accept(); + } else + TextEditor::keydown_event(event); + } }; ComboBox::ComboBox()