summaryrefslogtreecommitdiff
path: root/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-15 04:25:53 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-15 04:25:53 +0200
commit65e56eb72bee8175404ec2c27041bf0b98b6c3e9 (patch)
treef4f310f626ad4b9ca9b4a68342390958cd2fd45c /LibGUI
parentad731cc08f2cf84ec5fca5b1cf303fa0ac3cd390 (diff)
downloadserenity-65e56eb72bee8175404ec2c27041bf0b98b6c3e9.zip
GButton: Allow triggering a "click" by pressing Return when focused.
Diffstat (limited to 'LibGUI')
-rw-r--r--LibGUI/GButton.cpp8
-rw-r--r--LibGUI/GButton.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/LibGUI/GButton.cpp b/LibGUI/GButton.cpp
index c7e5202872..371d52c614 100644
--- a/LibGUI/GButton.cpp
+++ b/LibGUI/GButton.cpp
@@ -3,6 +3,7 @@
#include <SharedGraphics/StylePainter.h>
#include <AK/StringBuilder.h>
#include <LibGUI/GAction.h>
+#include <Kernel/KeyCode.h>
//#define GBUTTON_DEBUG
@@ -158,3 +159,10 @@ void GButton::set_icon(RetainPtr<GraphicsBitmap>&& icon)
m_icon = move(icon);
update();
}
+
+void GButton::keydown_event(GKeyEvent& event)
+{
+ if (event.key() == KeyCode::Key_Return)
+ click();
+ GWidget::keydown_event(event);
+}
diff --git a/LibGUI/GButton.h b/LibGUI/GButton.h
index 1175885edb..75e365580a 100644
--- a/LibGUI/GButton.h
+++ b/LibGUI/GButton.h
@@ -49,6 +49,7 @@ protected:
virtual void mousemove_event(GMouseEvent&) override;
virtual void enter_event(CEvent&) override;
virtual void leave_event(CEvent&) override;
+ virtual void keydown_event(GKeyEvent&) override;
private:
String m_caption;