1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-11 15:16:27 +01:00

Use a type distinction for key strings in normalized form...

... Such are not for display to the user.  They are appended to menu item
names to identify accelerators, and wxWidgets transforms them appropriately
for the operating system.
This commit is contained in:
Paul Licameli
2018-02-08 21:16:13 -05:00
parent 19014f22b7
commit e5052a1973
10 changed files with 256 additions and 236 deletions

View File

@@ -13,7 +13,7 @@
#include "Keyboard.h"
wxString KeyStringNormalize(const wxString & key)
NormalizedKeyString::NormalizedKeyString(const wxString & key)
{
#if defined(__WXMAC__)
wxString newkey;
@@ -44,16 +44,16 @@ wxString KeyStringNormalize(const wxString & key)
newkey += wxT("Ctrl+");
}
return newkey + temp.AfterLast(wxT('+'));
(wxString&)*this = newkey + temp.AfterLast(wxT('+'));
#else
return key;
(wxString&)*this = key;
#endif
}
wxString KeyStringDisplay(const wxString & key, bool usesSpecialChars)
wxString NormalizedKeyString::Display(bool usesSpecialChars) const
{
(void)usesSpecialChars;//compiler food
wxString newkey = KeyStringNormalize(key);
wxString newkey = *this;
#if defined(__WXMAC__)
if (!usesSpecialChars) {
@@ -75,7 +75,7 @@ wxString KeyStringDisplay(const wxString & key, bool usesSpecialChars)
return newkey;
}
wxString KeyEventToKeyString(const wxKeyEvent & event)
NormalizedKeyString KeyEventToKeyString(const wxKeyEvent & event)
{
wxString newStr = wxT("");
@@ -332,9 +332,9 @@ wxString KeyEventToKeyString(const wxKeyEvent & event)
newStr += wxT("NUMPAD_DIVIDE");
break;
default:
return wxT(""); // Don't do anything if we don't recognize the key
return {}; // Don't do anything if we don't recognize the key
}
}
return KeyStringNormalize(newStr);
return NormalizedKeyString{ newStr };
}