int keycode = 0;
int native = 0;
std::string type_str = "";
- std::vector<std::string> modifier_array;
+ mate::Dictionary modifier_list = mate::Dictionary::CreateEmpty(isolate);
data.Get(switches::kEventType, &type_str);
- data.Get(switches::kModifiers, &modifier_array);
+ data.Get(switches::kModifiers, &modifier_list);
data.Get(switches::kKeyCode, &keycode);
data.Get(switches::kNativeKeyCode, &native);
type = blink::WebInputEvent::Type::Char;
}
- for(std::vector<std::string>::iterator mod = modifier_array.begin(); mod != modifier_array.end(); ++mod) {
- if(mod->compare(event_types::kModifierIsKeyPad) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::IsKeyPad;
- }else if(mod->compare(event_types::kModifierIsAutoRepeat) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::IsAutoRepeat;
- }else if(mod->compare(event_types::kModifierIsLeft) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::IsLeft;
- }else if(mod->compare(event_types::kModifierIsRight) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::IsRight;
- }else if(mod->compare(event_types::kModifierShiftKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::ShiftKey;
- }else if(mod->compare(event_types::kModifierControlKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::ControlKey;
- }else if(mod->compare(event_types::kModifierAltKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::AltKey;
- }else if(mod->compare(event_types::kModifierMetaKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::MetaKey;
- }else if(mod->compare(event_types::kModifierCapsLockOn) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::CapsLockOn;
- }else if(mod->compare(event_types::kModifierNumLockOn) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::NumLockOn;
- }
+ std::map<std::string, bool> modifier_types;
+ modifier_types[event_types::kModifierIsKeyPad] = false;
+ modifier_types[event_types::kModifierIsAutoRepeat] = false;
+ modifier_types[event_types::kModifierIsLeft] = false;
+ modifier_types[event_types::kModifierIsRight] = false;
+ modifier_types[event_types::kModifierShiftKey] = false;
+ modifier_types[event_types::kModifierControlKey] = false;
+ modifier_types[event_types::kModifierAltKey] = false;
+ modifier_types[event_types::kModifierMetaKey] = false;
+ modifier_types[event_types::kModifierCapsLockOn] = false;
+ modifier_types[event_types::kModifierNumLockOn] = false;
+
+ for(std::map<std::string, bool>::iterator it = modifier_types.begin(); it != modifier_types.end(); ++it){
+ modifier_list.Get(it->first,&(it->second));
+
+ if(it->second) modifiers = modifiers & event_types::modifierStrToWebModifier(it->first);
}
window_->SendKeyboardEvent(type, modifiers, keycode, native);
int x, y, movementX, movementY, clickCount;
std::string type_str = "";
std::string button_str = "";
- std::vector<std::string> modifier_array;
+ mate::Dictionary modifier_list = mate::Dictionary::CreateEmpty(isolate);
blink::WebInputEvent::Type type = blink::WebInputEvent::Type::MouseMove;
blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::ButtonNone;
data.Get(switches::kEventType, &type_str);
data.Get(switches::kMouseEventButton, &button_str);
- data.Get(switches::kModifiers, &modifier_array);
+ data.Get(switches::kModifiers, &modifier_list);
if(type_str.compare(event_types::kMouseDown) == 0){
type = blink::WebInputEvent::Type::MouseDown;
type = blink::WebInputEvent::Type::MouseWheel;
}
- if(button_str.compare(event_types::kMouseLeftButton) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::LeftButtonDown;
- button = blink::WebMouseEvent::Button::ButtonLeft;
- }else if(button_str.compare(event_types::kMouseRightButton) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::RightButtonDown;
- button = blink::WebMouseEvent::Button::ButtonRight;
- }else if(button_str.compare(event_types::kMouseMiddleButton) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::MiddleButtonDown;
- button = blink::WebMouseEvent::Button::ButtonMiddle;
- }
-
- for(std::vector<std::string>::iterator mod = modifier_array.begin(); mod != modifier_array.end(); ++mod) {
- if(mod->compare(event_types::kModifierLeftButtonDown) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::LeftButtonDown;
- }else if(mod->compare(event_types::kModifierMiddleButtonDown) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::MiddleButtonDown;
- }else if(mod->compare(event_types::kModifierRightButtonDown) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::RightButtonDown;
- }else if(mod->compare(event_types::kModifierShiftKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::ShiftKey;
- }else if(mod->compare(event_types::kModifierControlKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::ControlKey;
- }else if(mod->compare(event_types::kModifierAltKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::AltKey;
- }else if(mod->compare(event_types::kModifierMetaKey) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::MetaKey;
- }else if(mod->compare(event_types::kModifierCapsLockOn) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::CapsLockOn;
- }else if(mod->compare(event_types::kModifierNumLockOn) == 0){
- modifiers = modifiers & blink::WebInputEvent::Modifiers::NumLockOn;
- }
+ std::map<std::string, bool> modifier_types;
+ modifier_types[event_types::kMouseLeftButton] = false;
+ modifier_types[event_types::kMouseRightButton] = false;
+ modifier_types[event_types::kMouseMiddleButton] = false;
+ modifier_types[event_types::kModifierLeftButtonDown] = false;
+ modifier_types[event_types::kModifierMiddleButtonDown] = false;
+ modifier_types[event_types::kModifierRightButtonDown] = false;
+ modifier_types[event_types::kModifierShiftKey] = false;
+ modifier_types[event_types::kModifierControlKey] = false;
+ modifier_types[event_types::kModifierAltKey] = false;
+ modifier_types[event_types::kModifierMetaKey] = false;
+ modifier_types[event_types::kModifierCapsLockOn] = false;
+ modifier_types[event_types::kModifierNumLockOn] = false;
+
+ for(std::map<std::string, bool>::iterator it = modifier_types.begin(); it != modifier_types.end(); ++it){
+ modifier_list.Get(it->first,&(it->second));
+
+ if(it->second) modifiers = modifiers & event_types::modifierStrToWebModifier(it->first);
}
if(type == blink::WebInputEvent::Type::MouseWheel){
// found in the LICENSE file.
#include "atom/common/event_types.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
namespace atom {
const char kModifierIsLeft[] = "left";
const char kModifierIsRight[] = "right";
-} // namespace switches
+int modifierStrToWebModifier(std::string modifier){
+ if(modifier.compare(event_types::kModifierLeftButtonDown) == 0){
+
+ return blink::WebInputEvent::Modifiers::LeftButtonDown;
+
+ }else if(modifier.compare(event_types::kModifierMiddleButtonDown) == 0){
+
+ return blink::WebInputEvent::Modifiers::MiddleButtonDown;
+
+ }else if(modifier.compare(event_types::kModifierRightButtonDown) == 0){
+
+ return blink::WebInputEvent::Modifiers::RightButtonDown;
+
+ }else if(modifier.compare(event_types::kMouseLeftButton) == 0){
+
+ return blink::WebInputEvent::Modifiers::LeftButtonDown;
+
+ }else if(modifier.compare(event_types::kMouseRightButton) == 0){
+
+ return blink::WebInputEvent::Modifiers::RightButtonDown;
+
+ }else if(modifier.compare(event_types::kMouseMiddleButton) == 0){
+
+ return blink::WebInputEvent::Modifiers::MiddleButtonDown;
+
+ }else if(modifier.compare(event_types::kModifierIsKeyPad) == 0){
+
+ return blink::WebInputEvent::Modifiers::IsKeyPad;
+
+ }else if(modifier.compare(event_types::kModifierIsAutoRepeat) == 0){
+
+ return blink::WebInputEvent::Modifiers::IsAutoRepeat;
+
+ }else if(modifier.compare(event_types::kModifierIsLeft) == 0){
+
+ return blink::WebInputEvent::Modifiers::IsLeft;
+
+ }else if(modifier.compare(event_types::kModifierIsRight) == 0){
+
+ return blink::WebInputEvent::Modifiers::IsRight;
+
+ }else if(modifier.compare(event_types::kModifierShiftKey) == 0){
+
+ return blink::WebInputEvent::Modifiers::ShiftKey;
+
+ }else if(modifier.compare(event_types::kModifierControlKey) == 0){
+
+ return blink::WebInputEvent::Modifiers::ControlKey;
+
+ }else if(modifier.compare(event_types::kModifierAltKey) == 0){
+
+ return blink::WebInputEvent::Modifiers::AltKey;
+
+ }else if(modifier.compare(event_types::kModifierMetaKey) == 0){
+
+ return blink::WebInputEvent::Modifiers::MetaKey;
+
+ }else if(modifier.compare(event_types::kModifierCapsLockOn) == 0){
+
+ return blink::WebInputEvent::Modifiers::CapsLockOn;
+
+ }else if(modifier.compare(event_types::kModifierNumLockOn) == 0){
+
+ return blink::WebInputEvent::Modifiers::NumLockOn;
+
+ }else{
+
+ return 0;
+
+ }
+}
+
+} // namespace event_types
} // namespace atom
* `middle` String - The middle button was pressed.
* `click-count` Integer - The number of clicks associated with the mouse event.
* `precise` Boolean - For the `wheel` event type, this option sets the `hasPreciseScrollingDeltas` option of the event.
- * `modifiers` Array of Strings - The modifier values associated with the event.
- * `left-button-down` String - The left mouse button was pressed.
- * `middle-button-down` String - The right mouse button was pressed.
- * `right-button-down` String - The middle mouse button was pressed.
- * `shift` String - The shift key was pressed.
- * `control` String - The control key was pressed.
- * `alt` String - The alt key was pressed.
- * `meta` String - The meta key was pressed.
- * `caps-lock` String - The caps-lock key was pressed.
- * `num-lock` String - The num-lock key was pressed.
+ * `modifiers` Object - The modifier values associated with the event.
+ * `left-button-down` Boolean - The left mouse button was pressed.
+ * `middle-button-down` Boolean - The right mouse button was pressed.
+ * `right-button-down` Boolean - The middle mouse button was pressed.
+ * `shift` Boolean - The shift key was pressed.
+ * `control` Boolean - The control key was pressed.
+ * `alt` Boolean - The alt key was pressed.
+ * `meta` Boolean - The meta key was pressed.
+ * `caps-lock` Boolean - The caps-lock key was on.
+ * `num-lock` Boolean - The num-lock key was on.
### BrowserWindow.sendKeyboardEvent(options)
* `char` String - Character event.
* `code` Integer - The key code of the key that generated the event.
* `native` Integer - The native key code of the key that generated the event.
- * `modifiers` Array of Strings - The modifier values associated with the event.
- * `keypad` String - Sets the `IsKeyPad` option of the event.
- * `auto-repeat` String - Sets the `IsAutoRepeat` option of the event.
- * `left` String - Sets the `IsLeft` option of the event.
- * `right` String - Sets the `IsRight` option of the event.
- * `shift` String - The shift key was pressed.
- * `control` String - The control key was pressed.
- * `alt` String - The alt key was pressed.
- * `meta` String - The meta key was pressed.
- * `caps-lock` String - The caps-lock key was pressed.
- * `num-lock` String - The num-lock key was pressed.
+ * `modifiers` Object - The modifier values associated with the event.
+ * `keypad` Boolean - Sets the `IsKeyPad` option of the event.
+ * `auto-repeat` Boolean - Sets the `IsAutoRepeat` option of the event.
+ * `left` Boolean - Sets the `IsLeft` option of the event.
+ * `right` Boolean - Sets the `IsRight` option of the event.
+ * `shift` Boolean - The shift key was pressed.
+ * `control` Boolean - The control key was pressed.
+ * `alt` Boolean - The alt key was pressed.
+ * `meta` Boolean - The meta key was pressed.
+ * `caps-lock` Boolean - The caps-lock key was on.
+ * `num-lock` Boolean - The num-lock key was on.
## Class: WebContents