LibWeb: Define a helper constant for the platform ctrl-ish key

For all intents and purposes, the cmd (super) key on macOS should be
treated as the ctrl key.
This commit is contained in:
Timothy Flynn 2024-08-01 12:45:41 -04:00 committed by Andreas Kling
commit 71b25e3e5a
Notes: github-actions[bot] 2024-08-02 06:08:11 +00:00
2 changed files with 16 additions and 0 deletions

View file

@ -8,6 +8,7 @@
#pragma once
#include <AK/EnumBits.h>
#include <AK/Platform.h>
#include <AK/Types.h>
namespace Web::UIEvents {
@ -169,6 +170,12 @@ enum KeyModifier {
Mod_Mask = Mod_Alt | Mod_Ctrl | Mod_Shift | Mod_Super | Mod_AltGr | Mod_Keypad,
Is_Press = 0x80,
#if defined(AK_OS_MACOS)
Mod_PlatformCtrl = Mod_Super,
#else
Mod_PlatformCtrl = Mod_Ctrl,
#endif
};
AK_ENUM_BITWISE_OPERATORS(KeyModifier);

View file

@ -56,6 +56,15 @@ public:
bool alt_key() const { return m_alt_key; }
bool meta_key() const { return m_meta_key; }
bool platform_ctrl_key() const
{
#if defined(AK_OS_MACOS)
return meta_key();
#else
return ctrl_key();
#endif
}
double movement_x() const { return m_movement_x; }
double movement_y() const { return m_movement_y; }