From 65e56eb72bee8175404ec2c27041bf0b98b6c3e9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 15 May 2019 04:25:53 +0200 Subject: [PATCH] GButton: Allow triggering a "click" by pressing Return when focused. --- LibGUI/GButton.cpp | 8 ++++++++ LibGUI/GButton.h | 1 + 2 files changed, 9 insertions(+) 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 #include #include +#include //#define GBUTTON_DEBUG @@ -158,3 +159,10 @@ void GButton::set_icon(RetainPtr&& 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;