diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-29 21:13:18 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-29 21:13:18 -0700 |
commit | c544c870d3cab2bcddda428d57807c389e8b04b1 (patch) | |
tree | 8d321acc229fb700b63f133566e5ae7eda7d8fc7 | |
parent | fb47868861f5d2ff6b21291dbe8cd6c6b8031336 (diff) |
support mouse wheel events
-rw-r--r-- | src/library_sdl.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index 9438653a..a72c71bd 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -356,7 +356,15 @@ var LibrarySDL = { event.movementX = event.mozMovementX; event.movementY = event.mozMovementY; // fall through - case 'keydown': case 'keyup': case 'mousedown': case 'mouseup': + case 'keydown': case 'keyup': case 'mousedown': case 'mouseup': case 'DOMMouseScroll': + if (event.type == 'DOMMouseScroll') { + event = { + type: 'mousedown', + button: event.detail > 0 ? 3 : 4, + pageX: event.pageX, + pageY: event.pageY + }; + } SDL.events.push(event); if (SDL.events.length >= 10000) { Module.printErr('SDL event queue full, dropping earliest event'); @@ -506,7 +514,7 @@ var LibrarySDL = { }, SDL_SetVideoMode: function(width, height, depth, flags) { - ['mousedown', 'mouseup', 'mousemove'].forEach(function(event) { + ['mousedown', 'mouseup', 'mousemove', 'DOMMouseScroll'].forEach(function(event) { Module['canvas'].addEventListener(event, SDL.receiveEvent, true); }); Module['canvas'].width = width; |