| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return 'U+' + o3djs.event.padWithLeadingZeroes(keyStr, 4); | 125 return 'U+' + o3djs.event.padWithLeadingZeroes(keyStr, 4); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 | 128 |
| 129 /** Takes a keyIdentifier string and remaps it to an ASCII/Unicode value | 129 /** Takes a keyIdentifier string and remaps it to an ASCII/Unicode value |
| 130 * suitable for javascript event handling. | 130 * suitable for javascript event handling. |
| 131 * @param {string} keyIdent a keyIdentifier string as generated above. | 131 * @param {string} keyIdent a keyIdentifier string as generated above. |
| 132 * @return {number} the numeric Unicode code point represented. | 132 * @return {number} the numeric Unicode code point represented. |
| 133 */ | 133 */ |
| 134 o3djs.event.keyIdentifierToChar = function(keyIdent) { | 134 o3djs.event.keyIdentifierToChar = function(keyIdent) { |
| 135 if (keyIdent) { | 135 if (keyIdent && typeof(keyIdent) == 'string') { |
| 136 switch (keyIdent) { | 136 switch (keyIdent) { |
| 137 case 'Enter': return 13; | 137 case 'Enter': return 13; |
| 138 case 'Left': return 37; | 138 case 'Left': return 37; |
| 139 case 'Right': return 39; | 139 case 'Right': return 39; |
| 140 case 'Up': return 38; | 140 case 'Up': return 38; |
| 141 case 'Down': return 40; | 141 case 'Down': return 40; |
| 142 } | 142 } |
| 143 if (keyIdent.indexOf('U+') == 0) | 143 if (keyIdent.indexOf('U+') == 0) |
| 144 return parseInt(keyIdent.substr(2).toUpperCase(), 16); | 144 return parseInt(keyIdent.substr(2).toUpperCase(), 16); |
| 145 } | 145 } |
| 146 return 0; | 146 return 0; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Extracts the key char in number form from the event, in a cross-browser | 150 * Extracts the key char in number form from the event, in a cross-browser |
| 151 * manner. | 151 * manner. |
| 152 * @param {!Event} event . | 152 * @param {!Event} event . |
| 153 * @return {number} unicode code point for the key. | 153 * @return {number} unicode code point for the key. |
| 154 */ | 154 */ |
| 155 o3djs.event.getEventKeyChar = function(event) { | 155 o3djs.event.getEventKeyChar = function(event) { |
| 156 if (!event) { | 156 if (!event) { |
| 157 event = window.event; | 157 event = window.event; |
| 158 } | 158 } |
| 159 var charCode = 0; | 159 var charCode = 0; |
| 160 if (event.keyIdentifier) | 160 if (event.keyIdentifier) |
| 161 charCode = o3djs.event.keyIdentifierToChar(event.keyIdentifier); | 161 charCode = o3djs.event.keyIdentifierToChar(event.keyIdentifier); |
| 162 if (!charCode) | 162 if (!charCode) |
| 163 charCode = (window.event) ? window.event.keyCode : event.charCode; | 163 charCode = (window.event) ? window.event.keyCode : event.charCode; |
| 164 if (!charCode) | 164 if (!charCode) |
| 165 charCode = event.keyCode; | 165 charCode = event.keyCode; |
| 166 return charCode; | 166 return charCode; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 | 169 |
| 170 /** | 170 /** |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 for (var index in listenerSet) { | 351 for (var index in listenerSet) { |
| 352 if (listenerSet[index] == handler) { | 352 if (listenerSet[index] == handler) { |
| 353 if (listenerSet.length == 1) { | 353 if (listenerSet.length == 1) { |
| 354 pluginObject.client.clearEventCallback(type); | 354 pluginObject.client.clearEventCallback(type); |
| 355 } | 355 } |
| 356 listenerSet.splice(index, 1); | 356 listenerSet.splice(index, 1); |
| 357 break; | 357 break; |
| 358 } | 358 } |
| 359 } | 359 } |
| 360 }; | 360 }; |
| OLD | NEW |