| 72 | }; |
| 73 | |
| 74 | bool BFMenu::ParseHotKey(const StringImpl& hotKey) |
| 75 | { |
| 76 | String aHotKey = ToUpper(hotKey); |
| 77 | if (aHotKey.StartsWith("#")) |
| 78 | return false; |
| 79 | |
| 80 | while (true) |
| 81 | { |
| 82 | int idx = (int)aHotKey.IndexOf('+'); |
| 83 | if (idx == -1) |
| 84 | idx = (int)aHotKey.IndexOf('-'); |
| 85 | if (idx == -1) |
| 86 | break; |
| 87 | |
| 88 | String aModifier = Trim(aHotKey.Substring(0, idx)); |
| 89 | aHotKey = Trim(aHotKey.Substring(idx + 1)); |
| 90 | |
| 91 | if (aModifier == "SHIFT") |
| 92 | mKeyShift = true; |
| 93 | else if (aModifier == "CTRL") |
| 94 | mKeyCtrl = true; |
| 95 | else if (aModifier == "ALT") |
| 96 | mKeyAlt = true; |
| 97 | else |
| 98 | { |
| 99 | BF_FATAL("Unknown hotkey modifier"); |
| 100 | return false; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if (aHotKey.length() == 1) |
| 105 | { |
| 106 | if (aHotKey == ",") |
| 107 | mKeyCode = /*VK_COMMA*/0xBC; |
| 108 | else |
| 109 | mKeyCode = (int) aHotKey[0]; |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | int count = sizeof(gNamedKeys) / sizeof(BFNamedVirtKey); |
| 114 | for (int i = 0; i < count; i++) |
| 115 | { |
| 116 | if (aHotKey == gNamedKeys[i].mName) |
| 117 | { |
| 118 | mKeyCode = gNamedKeys[i].mKeyCode; |
| 119 | if ((mKeyCode == VK_PAUSE) && (mKeyCtrl)) |
| 120 | { |
| 121 | // Ctrl-Pause is really "Cancel" |
| 122 | mKeyCode = VK_CANCEL; |
| 123 | } |
| 124 | return true; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | BF_FATAL("Unknown hotkey key name"); |
| 129 | return false; |
| 130 | } |
| 131 |
no test coverage detected