1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibGUI: Make ComboBox text editor release focus when Escape is pressed

This commit is contained in:
kleines Filmröllchen 2021-09-28 17:17:36 +02:00 committed by Andreas Kling
parent 1349b8b10f
commit f922ffb032

View file

@ -7,10 +7,12 @@
#include <LibGUI/Button.h>
#include <LibGUI/ComboBox.h>
#include <LibGUI/Desktop.h>
#include <LibGUI/Event.h>
#include <LibGUI/ListView.h>
#include <LibGUI/Model.h>
#include <LibGUI/Scrollbar.h>
#include <LibGUI/TextBox.h>
#include <LibGUI/TextEditor.h>
#include <LibGUI/Window.h>
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()