]> khamidou — GitHub mirrors - electron.git/commitdiff
Add metaKey
authorCheng Zhao <zcbenz@gmail.com>
Wed, 29 Jul 2015 06:44:08 +0000 (14:44 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 29 Jul 2015 06:44:08 +0000 (14:44 +0800)
atom/browser/api/atom_api_tray.cc
atom/browser/ui/win/notify_icon_host.cc
docs/api/tray.md

index 82f78519aeb3374ce017d296226adf60bfec0567..0f07737da2bfe67ac0a5b85bce369908615d595e 100644 (file)
@@ -136,6 +136,7 @@ v8::Local<v8::Object> Tray::ModifiersToObject(v8::Isolate* isolate,
   obj.Set("shiftKey", static_cast<bool>(modifiers & ui::EF_SHIFT_DOWN));
   obj.Set("ctrlKey", static_cast<bool>(modifiers & ui::EF_CONTROL_DOWN));
   obj.Set("altKey", static_cast<bool>(modifiers & ui::EF_ALT_DOWN));
+  obj.Set("metaKey", static_cast<bool>(modifiers & ui::EF_COMMAND_DOWN));
   return obj.GetHandle();
 }
 
index c34e14375e7605d4e4bb61ea7cebedcae0a38f53..2c84837e714d62ba22ff553628cfd6234204a4ba 100644 (file)
@@ -5,6 +5,7 @@
 #include "atom/browser/ui/win/notify_icon_host.h"
 
 #include <commctrl.h>
+#include <winuser.h>
 
 #include "atom/browser/ui/win/notify_icon.h"
 #include "base/bind.h"
@@ -28,6 +29,11 @@ const UINT kBaseIconId = 2;
 
 const wchar_t kNotifyIconHostWindowClass[] = L"Electron_NotifyIconHostWindow";
 
+bool IsWinPressed() {
+  return ((::GetKeyState(VK_LWIN) & 0x8000) == 0x8000) ||
+         ((::GetKeyState(VK_RWIN) & 0x8000) == 0x8000);
+}
+
 int GetKeyboardModifers() {
   int modifiers = ui::EF_NONE;
   if (base::win::IsShiftPressed())
@@ -36,6 +42,8 @@ int GetKeyboardModifers() {
     modifiers |= ui::EF_CONTROL_DOWN;
   if (base::win::IsAltPressed())
     modifiers |= ui::EF_ALT_DOWN;
+  if (IsWinPressed())
+    modifiers |= ui::EF_COMMAND_DOWN;
   return modifiers;
 }
 
index 5c8c88018f71b93276a7ec0db871e7f40b471928..3d3ebc280f5ac28e6266fc62108ef7201ded87e3 100644 (file)
@@ -51,6 +51,7 @@ Creates a new tray icon associated with the `image`.
   * `altKey` Boolean
   * `shiftKey` Boolean
   * `ctrlKey` Boolean
+  * `metaKey` Boolean
 * `bounds` Object - the bounds of tray icon
   * `x` Integer
   * `y` Integer
@@ -67,6 +68,7 @@ __Note:__ The `bounds` payload is only implemented on OS X and Windows 7 or newe
   * `altKey` Boolean
   * `shiftKey` Boolean
   * `ctrlKey` Boolean
+  * `metaKey` Boolean
 * `bounds` Object - the bounds of tray icon
   * `x` Integer
   * `y` Integer
@@ -83,6 +85,7 @@ __Note:__ This is only implemented on OS X and Windows.
   * `altKey` Boolean
   * `shiftKey` Boolean
   * `ctrlKey` Boolean
+  * `metaKey` Boolean
 * `bounds` Object - the bounds of tray icon
   * `x` Integer
   * `y` Integer