aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-03-24 15:48:15 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-03-24 15:48:15 -0700
commiteb3f5116a5006d03c9e0f94f797b9dfd9dee3aee (patch)
treeffd260e5b6a6c27c8073c468cfd972d3091d25f8 /tests
parent6ad919104f7c00ae3774be7d275d9a259869dbc9 (diff)
make mouse events relative to canvas, and at right frequency
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py14
-rw-r--r--tests/sdl_mouse.c3
2 files changed, 10 insertions, 7 deletions
diff --git a/tests/runner.py b/tests/runner.py
index fa566c33..0106df5d 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6416,23 +6416,23 @@ f.close()
if (button) {
var event1 = document.createEvent("MouseEvents");
event1.initMouseEvent('mousedown', true, true, window,
- 1, x, y, x, y,
+ 1, Module['canvas'].offsetLeft + x, Module['canvas'].offsetTop + y, Module['canvas'].offsetLeft + x, Module['canvas'].offsetTop + y,
0, 0, 0, 0,
button, null);
- dispatchEvent(event1);
+ Module['canvas'].dispatchEvent(event1);
var event2 = document.createEvent("MouseEvents");
event2.initMouseEvent('mouseup', true, true, window,
- 1, x, y, x, y,
+ 1, Module['canvas'].offsetLeft + x, Module['canvas'].offsetTop + y, Module['canvas'].offsetLeft + x, Module['canvas'].offsetTop + y,
0, 0, 0, 0,
button, null);
- dispatchEvent(event2);
+ Module['canvas'].dispatchEvent(event2);
} else {
var event1 = document.createEvent("MouseEvents");
- event1.initMouseEvent('mouseover', true, true, window,
- 0, x, y, x, y,
+ event1.initMouseEvent('mousemove', true, true, window,
+ 0, Module['canvas'].offsetLeft + x, Module['canvas'].offsetTop + y, Module['canvas'].offsetLeft + x, Module['canvas'].offsetTop + y,
0, 0, 0, 0,
0, null);
- dispatchEvent(event1);
+ Module['canvas'].dispatchEvent(event1);
}
}
''')
diff --git a/tests/sdl_mouse.c b/tests/sdl_mouse.c
index 87619ef2..eb731186 100644
--- a/tests/sdl_mouse.c
+++ b/tests/sdl_mouse.c
@@ -43,6 +43,9 @@ int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
+ SDL_Rect rect = { 0, 0, 600, 450 };
+ SDL_FillRect(screen, &rect, 0x2244ff00);
+
emscripten_run_script("simulateMouseEvent(10, 20, 0)"); // move from 0,0 to 10,20
emscripten_run_script("simulateMouseEvent(10, 20, 1)"); // click
emscripten_run_script("simulateMouseEvent(30, 77, 0)"); // move some more