mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 05:57:41 +00:00
LibGUI: Make ComboBox text editor release focus when Escape is pressed
This commit is contained in:
parent
1349b8b10f
commit
f922ffb032
1 changed files with 12 additions and 0 deletions
|
@ -7,10 +7,12 @@
|
||||||
#include <LibGUI/Button.h>
|
#include <LibGUI/Button.h>
|
||||||
#include <LibGUI/ComboBox.h>
|
#include <LibGUI/ComboBox.h>
|
||||||
#include <LibGUI/Desktop.h>
|
#include <LibGUI/Desktop.h>
|
||||||
|
#include <LibGUI/Event.h>
|
||||||
#include <LibGUI/ListView.h>
|
#include <LibGUI/ListView.h>
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
#include <LibGUI/Scrollbar.h>
|
#include <LibGUI/Scrollbar.h>
|
||||||
#include <LibGUI/TextBox.h>
|
#include <LibGUI/TextBox.h>
|
||||||
|
#include <LibGUI/TextEditor.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
REGISTER_WIDGET(GUI, ComboBox)
|
REGISTER_WIDGET(GUI, ComboBox)
|
||||||
|
@ -36,6 +38,16 @@ private:
|
||||||
if (on_mousewheel)
|
if (on_mousewheel)
|
||||||
on_mousewheel(event.wheel_delta());
|
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()
|
ComboBox::ComboBox()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue