diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2012-04-02 13:54:44 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2012-04-02 13:54:44 -0400 |
commit | 0a0f93a8f5e0419ab4dd85b3854ed89d63b62969 (patch) | |
tree | d5e8890f6fc5768c63dae36555021603a24d518e /src/library_gl.js | |
parent | 4ef0218e0f3491a0ad46fb8b5491a23acc273a6f (diff) |
event.preventDefault if GLUT is handling events
Diffstat (limited to 'src/library_gl.js')
-rw-r--r-- | src/library_gl.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index b3d55f88..91f7d353 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -486,9 +486,11 @@ var LibraryGLUT = { GLUT.lastX = event['clientX']; GLUT.lastY = event['clientY']; if (GLUT.buttons == 0 && GLUT.passiveMotionFunc) { + event.preventDefault (); GLUT.saveModifiers(event); FUNCTION_TABLE[GLUT.passiveMotionFunc](GLUT.lastX, GLUT.lastY); } else if (GLUT.buttons != 0 && GLUT.motionFunc) { + event.preventDefault (); GLUT.saveModifiers(event); FUNCTION_TABLE[GLUT.motionFunc](GLUT.lastX, GLUT.lastY); } @@ -529,15 +531,20 @@ var LibraryGLUT = { onKeydown: function(event) { if (GLUT.specialFunc || GLUT.keyboardFunc) { - GLUT.saveModifiers(event); var key = GLUT.getSpecialKey(event['keyCode']); if (key !== null) { - if( GLUT.specialFunc ) FUNCTION_TABLE[GLUT.specialFunc](key, GLUT.lastX, GLUT.lastY); + if( GLUT.specialFunc ) { + event.preventDefault (); + GLUT.saveModifiers(event); + FUNCTION_TABLE[GLUT.specialFunc](key, GLUT.lastX, GLUT.lastY); + } } else { key = GLUT.getASCIIKey(event['keyCode']); if( key !== null && GLUT.keyboardFunc ) { + event.preventDefault (); + GLUT.saveModifiers(event); FUNCTION_TABLE[GLUT.keyboardFunc](event['keyCode'], GLUT.lastX, GLUT.lastY); } } @@ -546,15 +553,20 @@ var LibraryGLUT = { onKeyup: function(event) { if (GLUT.specialUpFunc || GLUT.keyboardUpFunc) { - GLUT.saveModifiers(event); var key = GLUT.getSpecialKey(event['keyCode']); if (key !== null) { - if(GLUT.specialUpFunc) FUNCTION_TABLE[GLUT.specialUpFunc](key, GLUT.lastX, GLUT.lastY); + if(GLUT.specialUpFunc) { + event.preventDefault (); + GLUT.saveModifiers(event); + FUNCTION_TABLE[GLUT.specialUpFunc](key, GLUT.lastX, GLUT.lastY); + } } else { key = GLUT.getASCIIKey(event['keyCode']); if( key !== null && GLUT.keyboardUpFunc ) { + event.preventDefault (); + GLUT.saveModifiers(event); FUNCTION_TABLE[GLUT.keyboardUpFunc](event['keyCode'], GLUT.lastX, GLUT.lastY); } } @@ -567,6 +579,7 @@ var LibraryGLUT = { GLUT.buttons |= (1 << event['button']); if(GLUT.mouseFunc){ + event.preventDefault (); GLUT.saveModifiers(event); FUNCTION_TABLE[GLUT.mouseFunc](event['button'], 0/*GLUT_DOWN*/, GLUT.lastX, GLUT.lastY); } @@ -578,6 +591,7 @@ var LibraryGLUT = { GLUT.buttons &= ~(1 << event['button']); if(GLUT.mouseFunc) { + event.preventDefault (); GLUT.saveModifiers(event); FUNCTION_TABLE[GLUT.mouseFunc](event['button'], 1/*GLUT_UP*/, GLUT.lastX, GLUT.lastY); } |