aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-08-29 17:50:22 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-08-29 17:50:22 -0700
commita6b7f17e9d1acf253bd2b13ca189f89ceaed3dcd (patch)
treed5fc990d9b1ff8aaf0ebc55592a8327163f955ec
parent2d206b313f2c2292f8b365ac22132d4d13af391e (diff)
support mousewheel event
-rw-r--r--src/library_sdl.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index a74dc785..a7ad8142 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -350,11 +350,19 @@ var LibrarySDL = {
event['movementX'] = event['mozMovementX'];
event['movementY'] = event['mozMovementY'];
// fall through
- case 'keydown': case 'keyup': case 'mousedown': case 'mouseup': case 'DOMMouseScroll':
- if (event.type == 'DOMMouseScroll') {
- event = {
+ case 'keydown': case 'keyup': case 'mousedown': case 'mouseup': case 'DOMMouseScroll': case 'mousewheel':
+ if (event.type == 'DOMMouseScroll' || event.type == 'mousewheel') {
+ var button = (event.type == 'DOMMouseScroll' ? event.detail : -event.wheelDelta) > 0 ? 4 : 3;
+ var event2 = {
type: 'mousedown',
- button: event.detail > 0 ? 4 : 3,
+ button: button,
+ pageX: event.pageX,
+ pageY: event.pageY
+ };
+ SDL.events.push(event2);
+ event = {
+ type: 'mouseup',
+ button: button,
pageX: event.pageX,
pageY: event.pageY
};
@@ -620,7 +628,7 @@ var LibrarySDL = {
},
SDL_SetVideoMode: function(width, height, depth, flags) {
- ['mousedown', 'mouseup', 'mousemove', 'DOMMouseScroll', 'mouseout'].forEach(function(event) {
+ ['mousedown', 'mouseup', 'mousemove', 'DOMMouseScroll', 'mousewheel', 'mouseout'].forEach(function(event) {
Module['canvas'].addEventListener(event, SDL.receiveEvent, true);
});
Module['canvas'].width = width;