Adding option to specify the button of WebMouseEvent.

This commit is contained in:
Heilig Benedek 2015-09-25 13:01:52 +02:00
parent 5de1b20935
commit bb102717b4

View file

@ -77,6 +77,21 @@ struct Converter<blink::WebInputEvent::Type> {
} }
}; };
template<>
struct Converter<blink::WebMouseEvent::Button> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
blink::WebMouseEvent::Button* out) {
std::string button = base::StringToLowerASCII(V8ToString(val));
if (button == "left")
*out = blink::WebMouseEvent::Button::ButtonLeft;
else if (button == "middle")
*out = blink::WebMouseEvent::Button::ButtonMiddle;
else if (button == "right")
*out = blink::WebMouseEvent::Button::ButtonRight;
return true;
}
};
template<> template<>
struct Converter<blink::WebInputEvent::Modifiers> { struct Converter<blink::WebInputEvent::Modifiers> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val, static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
@ -176,6 +191,7 @@ bool Converter<blink::WebMouseEvent>::FromV8(
return false; return false;
if (!dict.Get("x", &out->x) || !dict.Get("y", &out->y)) if (!dict.Get("x", &out->x) || !dict.Get("y", &out->y))
return false; return false;
dict.Get("button", &out->button);
dict.Get("globalX", &out->globalX); dict.Get("globalX", &out->globalX);
dict.Get("globalY", &out->globalY); dict.Get("globalY", &out->globalY);
dict.Get("movementX", &out->movementX); dict.Get("movementX", &out->movementX);