From 4d93fb4789f8a1b8d98c6159304acf72c9f5e3aa Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Tue, 7 Jun 2022 22:43:08 +0200 Subject: [PATCH] LibGUI: Add a helper for VerticalDirection The function converts Key_[Up, Down] to the corresponding VerticalDirection. --- Userland/Libraries/LibGUI/Widget.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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