mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 21:10:30 +00:00
GButton: Allow triggering a "click" by pressing Return when focused.
This commit is contained in:
parent
ad731cc08f
commit
65e56eb72b
Notes:
sideshowbarker
2024-07-19 14:08:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/65e56eb72be
2 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue