Skip to content

Commit bb10271

Browse files
committed
Adding option to specify the button of WebMouseEvent.
1 parent 5de1b20 commit bb10271

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

atom/common/native_mate_converters/blink_converter.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ struct Converter<blink::WebInputEvent::Type> {
7777
}
7878
};
7979

80+
template<>
81+
struct Converter<blink::WebMouseEvent::Button> {
82+
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
83+
blink::WebMouseEvent::Button* out) {
84+
std::string button = base::StringToLowerASCII(V8ToString(val));
85+
if (button == "left")
86+
*out = blink::WebMouseEvent::Button::ButtonLeft;
87+
else if (button == "middle")
88+
*out = blink::WebMouseEvent::Button::ButtonMiddle;
89+
else if (button == "right")
90+
*out = blink::WebMouseEvent::Button::ButtonRight;
91+
return true;
92+
}
93+
};
94+
8095
template<>
8196
struct Converter<blink::WebInputEvent::Modifiers> {
8297
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
@@ -176,6 +191,7 @@ bool Converter<blink::WebMouseEvent>::FromV8(
176191
return false;
177192
if (!dict.Get("x", &out->x) || !dict.Get("y", &out->y))
178193
return false;
194+
dict.Get("button", &out->button);
179195
dict.Get("globalX", &out->globalX);
180196
dict.Get("globalY", &out->globalY);
181197
dict.Get("movementX", &out->movementX);

0 commit comments

Comments
 (0)