A label that may have its accelerator disabled. The problem is that as soon as we show accelerators in the menu, the menu might catch them in normal wxWidgets processing, rather than passing the key presses on to the controls that had the focus. We would like all the menu accelerators to be disabled, in fact.
| 264 | // to the controls that had the focus. We would like all the menu accelerators to be |
| 265 | // disabled, in fact. |
| 266 | static wxString |
| 267 | FormatLabelWithDisabledAccel(const CommandManager::CommandListEntry &entry) |
| 268 | { |
| 269 | auto label = entry.label.Translation(); |
| 270 | #if 1 |
| 271 | wxString Accel; |
| 272 | do{ |
| 273 | if (!entry.key.empty()) |
| 274 | { |
| 275 | // Dummy accelerator that looks Ok in menus but is non functional. |
| 276 | // Note the space before the key. |
| 277 | #ifdef __WXMSW__ |
| 278 | // using GET to compose menu item name for wxWidgets |
| 279 | auto key = entry.key.GET(); |
| 280 | Accel = wxString("\t ") + key; |
| 281 | if( key.StartsWith("Left" )) break; |
| 282 | if( key.StartsWith("Right")) break; |
| 283 | if( key.StartsWith("Up" )) break; |
| 284 | if( key.StartsWith("Down")) break; |
| 285 | if( key.StartsWith("Return")) break; |
| 286 | if( key.StartsWith("Tab")) break; |
| 287 | if( key.StartsWith("Shift+Tab")) break; |
| 288 | if( key.StartsWith("0")) break; |
| 289 | if( key.StartsWith("1")) break; |
| 290 | if( key.StartsWith("2")) break; |
| 291 | if( key.StartsWith("3")) break; |
| 292 | if( key.StartsWith("4")) break; |
| 293 | if( key.StartsWith("5")) break; |
| 294 | if( key.StartsWith("6")) break; |
| 295 | if( key.StartsWith("7")) break; |
| 296 | if( key.StartsWith("8")) break; |
| 297 | if( key.StartsWith("9")) break; |
| 298 | // Uncomment the below so as not to add the illegal accelerators. |
| 299 | // Accel = ""; |
| 300 | //if( entry.key.StartsWith("Space" )) break; |
| 301 | // These ones appear to be illegal already and mess up accelerator processing. |
| 302 | if( key.StartsWith("NUMPAD_ENTER" )) break; |
| 303 | if( key.StartsWith("Backspace" )) break; |
| 304 | if( key.StartsWith("Delete" )) break; |
| 305 | |
| 306 | // https://github.com/audacity/audacity/issues/4457 |
| 307 | // This code was proposed by David Bailes to fix |
| 308 | // the decimal separator input in wxTextCtrls that |
| 309 | // are children of the main window. |
| 310 | if( key.StartsWith(",") ) break; |
| 311 | if( key.StartsWith(".") ) break; |
| 312 | |
| 313 | // https://github.com/audacity/audacity/issues/5868 |
| 314 | // On German and Norwegian keyboards, [ and ] are |
| 315 | // AltGr 8 and AltGr 9. On Windows typing 8 or 9 match |
| 316 | // [ or ] repectively when they are accelerators in menus. |
| 317 | if ( key.StartsWith("[") ) break; |
| 318 | if ( key.StartsWith("]") ) break; |
| 319 | |
| 320 | #endif |
| 321 | //wxLogDebug("Added Accel:[%s][%s]", entry.label, entry.key ); |
| 322 | // Normal accelerator. |
| 323 | // using GET to compose menu item name for wxWidgets |
no test coverage detected