diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2022-06-07 22:43:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-15 12:33:59 +0200 |
commit | 4d93fb4789f8a1b8d98c6159304acf72c9f5e3aa (patch) | |
tree | 9a3f530bc34b48bfbb9e23eb84cf32da98342c8b /Userland | |
parent | 0bcfbdb072b4361350b0996dbfdf7215348f389b (diff) | |
download | serenity-4d93fb4789f8a1b8d98c6159304acf72c9f5e3aa.zip |
LibGUI: Add a helper for VerticalDirection
The function converts Key_[Up, Down] to the corresponding
VerticalDirection.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/Widget.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index 82bfcc0c63..830007fa8e 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -52,6 +52,15 @@ enum class VerticalDirection { Down }; +constexpr VerticalDirection key_code_to_vertical_direction(KeyCode const& key) +{ + if (key == Key_Up) + return VerticalDirection::Up; + if (key == Key_Down) + return VerticalDirection::Down; + VERIFY_NOT_REACHED(); +} + enum class AllowCallback { No, Yes |