| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the Adblock Plus build tools, | 2 * This file is part of the Adblock Plus build tools, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 Cu.import("resource://gre/modules/Services.jsm"); | 18 Cu.import("resource://gre/modules/Services.jsm"); |
| 19 | 19 |
| 20 let validModifiers = | 20 let validModifiers = |
| 21 { | 21 { |
| 22 ACCEL: "control", | 22 ACCEL: null, |
| 23 CTRL: "control", | 23 CTRL: "control", |
| 24 CONTROL: "control", | 24 CONTROL: "control", |
| 25 SHIFT: "shift", | 25 SHIFT: "shift", |
| 26 ALT: "alt", | 26 ALT: "alt", |
| 27 META: "meta", | 27 META: "meta", |
| 28 __proto__: null | 28 __proto__: null |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Sets the correct value of validModifiers.ACCEL. | 32 * Sets the correct value of validModifiers.ACCEL. |
| 33 */ | 33 */ |
| 34 function initAccelKey() | 34 function initAccelKey() |
| 35 { | 35 { |
| 36 validModifiers.ACCEL = "control"; |
| 36 try | 37 try |
| 37 { | 38 { |
| 38 let accelKey = Services.prefs.getIntPref("ui.key.accelKey"); | 39 let accelKey = Services.prefs.getIntPref("ui.key.accelKey"); |
| 39 if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL) | 40 if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL) |
| 40 validModifiers.ACCEL = "control"; | 41 validModifiers.ACCEL = "control"; |
| 41 else if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_ALT) | 42 else if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_ALT) |
| 42 validModifiers.ACCEL = "alt"; | 43 validModifiers.ACCEL = "alt"; |
| 43 else if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_META) | 44 else if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_META) |
| 44 validModifiers.ACCEL = "meta"; | 45 validModifiers.ACCEL = "meta"; |
| 45 } | 46 } |
| 46 catch(e) | 47 catch(e) |
| 47 { | 48 { |
| 48 validModifiers.ACCEL = "control"; | |
| 49 Cu.reportError(e); | 49 Cu.reportError(e); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 exports.KeySelector = KeySelector; | 53 exports.KeySelector = KeySelector; |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * This class provides capabilities to find and use available keyboard shortcut | 56 * This class provides capabilities to find and use available keyboard shortcut |
| 57 * keys. | 57 * keys. |
| 58 * @param {ChromeWindow} window the window where to look up existing shortcut | 58 * @param {ChromeWindow} window the window where to look up existing shortcut |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 return false; | 219 return false; |
| 220 if (key.meta != event.metaKey || key.control != event.ctrlKey) | 220 if (key.meta != event.metaKey || key.control != event.ctrlKey) |
| 221 return false; | 221 return false; |
| 222 | 222 |
| 223 if (key.char && event.charCode && String.fromCharCode(event.charCode).toUpperC
ase() == key.char) | 223 if (key.char && event.charCode && String.fromCharCode(event.charCode).toUpperC
ase() == key.char) |
| 224 return true; | 224 return true; |
| 225 if (key.code && event.keyCode && event.keyCode == key.code) | 225 if (key.code && event.keyCode && event.keyCode == key.code) |
| 226 return true; | 226 return true; |
| 227 return false; | 227 return false; |
| 228 }; | 228 }; |
| OLD | NEW |