فهرست منبع

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.
Timothy Flynn 11 ماه پیش
والد
کامیت
71b25e3e5a
2فایلهای تغییر یافته به همراه16 افزوده شده و 0 حذف شده
  1. 7 0
      Userland/Libraries/LibWeb/UIEvents/KeyCode.h
  2. 9 0
      Userland/Libraries/LibWeb/UIEvents/MouseEvent.h

+ 7 - 0
Userland/Libraries/LibWeb/UIEvents/KeyCode.h

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

+ 9 - 0
Userland/Libraries/LibWeb/UIEvents/MouseEvent.h

@@ -56,6 +56,15 @@ public:
     bool alt_key() const { return m_alt_key; }
     bool alt_key() const { return m_alt_key; }
     bool meta_key() const { return m_meta_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_x() const { return m_movement_x; }
     double movement_y() const { return m_movement_y; }
     double movement_y() const { return m_movement_y; }