diff options
author | vangelis@google.com <vangelis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 00:58:03 +0000 |
---|---|---|
committer | vangelis@google.com <vangelis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 00:58:03 +0000 |
commit | fcf211a7317718414191405615fc4891e821140f (patch) | |
tree | 570b0b8c98bc8ac7ae8e675804ab30d49db88af6 /o3d/samples | |
parent | e533016a3dc8599a82fd66457ee2ccff6d244bd1 (diff) | |
download | chromium_src-fcf211a7317718414191405615fc4891e821140f.zip chromium_src-fcf211a7317718414191405615fc4891e821140f.tar.gz chromium_src-fcf211a7317718414191405615fc4891e821140f.tar.bz2 |
Fixing bug #152 (pressing "T" doens't leave a trail in the particle samples only in Chrome).
The problem had to do with the translation of the key codes. There's another issue that surfaced
with the event.js code in IE when the events are handled by methods running in V8. In that situation
it appears that event.keyIdentifier isn't actually a string and IE barfs when we call keyIdent.indexOf(). I added
a check to make sure it's a string but I don't know if the fix really belongs somewhere in the V8 / IE bridge
Review URL: http://codereview.chromium.org/218002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27308 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples')
-rw-r--r-- | o3d/samples/o3djs/event.js | 8 | ||||
-rw-r--r-- | o3d/samples/particles.html | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/o3d/samples/o3djs/event.js b/o3d/samples/o3djs/event.js index 75fe45c..f5de0d3 100644 --- a/o3d/samples/o3djs/event.js +++ b/o3d/samples/o3djs/event.js @@ -132,7 +132,7 @@ o3djs.event.getKeyIdentifier = function(charCode, keyCode) { * @return {number} the numeric Unicode code point represented. */ o3djs.event.keyIdentifierToChar = function(keyIdent) { - if (keyIdent) { + if (keyIdent && typeof(keyIdent) == 'string') { switch (keyIdent) { case 'Enter': return 13; case 'Left': return 37; @@ -140,8 +140,8 @@ o3djs.event.keyIdentifierToChar = function(keyIdent) { case 'Up': return 38; case 'Down': return 40; } - if (keyIdent.indexOf('U+') == 0) - return parseInt(keyIdent.substr(2).toUpperCase(), 16); + if (keyIdent.indexOf('U+') == 0) + return parseInt(keyIdent.substr(2).toUpperCase(), 16); } return 0; }; @@ -157,7 +157,7 @@ o3djs.event.getEventKeyChar = function(event) { event = window.event; } var charCode = 0; - if (event.keyIdentifier) + if (event.keyIdentifier) charCode = o3djs.event.keyIdentifierToChar(event.keyIdentifier); if (!charCode) charCode = (window.event) ? window.event.keyCode : event.charCode; diff --git a/o3d/samples/particles.html b/o3d/samples/particles.html index 2b4710c..bc28344 100644 --- a/o3d/samples/particles.html +++ b/o3d/samples/particles.html @@ -198,12 +198,12 @@ function onKeyPress(event) { function onKeyDown(event) { event = event || window.event; - g_keyDown[event.keyCode] = true; + g_keyDown[o3djs.event.getEventKeyChar(event)] = true; } function onKeyUp(event) { event = event || window.event; - g_keyDown[event.keyCode] = false; + g_keyDown[o3djs.event.getEventKeyChar(event)] = false; } function setupFlame() { |