summaryrefslogtreecommitdiff
path: root/indra/llwindow/llkeyboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow/llkeyboard.cpp')
-rw-r--r--indra/llwindow/llkeyboard.cpp88
1 files changed, 49 insertions, 39 deletions
diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp
index f6f6c3931c..5404ac50e5 100644
--- a/indra/llwindow/llkeyboard.cpp
+++ b/indra/llwindow/llkeyboard.cpp
@@ -327,7 +327,7 @@ BOOL LLKeyboard::keyFromString(const std::string& str, KEY *key)
// static
-std::string LLKeyboard::stringFromKey(KEY key)
+std::string LLKeyboard::stringFromKey(KEY key, bool translate)
{
std::string res = get_if_there(sKeysToNames, key, std::string());
if (res.empty())
@@ -338,16 +338,60 @@ std::string LLKeyboard::stringFromKey(KEY key)
res = std::string(buffer);
}
- LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator;
- if (trans != NULL)
+ if (translate)
{
- res = trans(res.c_str());
+ LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator;
+ if (trans != NULL)
+ {
+ res = trans(res.c_str());
+ }
}
return res;
}
+//static
+std::string LLKeyboard::stringFromAccelerator(MASK accel_mask)
+{
+ std::string res;
+
+ LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator;
+
+ if (trans == NULL)
+ {
+ LL_ERRS() << "No mKeyStringTranslator" << LL_ENDL;
+ return res;
+ }
+ // Append any masks
+#ifdef LL_DARWIN
+ // Standard Mac names for modifier keys in menu equivalents
+ // We could use the symbol characters, but they only exist in certain fonts.
+ if (accel_mask & MASK_CONTROL)
+ {
+ if (accel_mask & MASK_MAC_CONTROL)
+ {
+ res.append(trans("accel-mac-control"));
+ }
+ else
+ {
+ res.append(trans("accel-mac-command")); // Symbol would be "\xE2\x8C\x98"
+ }
+ }
+ if (accel_mask & MASK_ALT)
+ res.append(trans("accel-mac-option")); // Symbol would be "\xE2\x8C\xA5"
+ if (accel_mask & MASK_SHIFT)
+ res.append(trans("accel-mac-shift")); // Symbol would be "\xE2\x8C\xA7"
+#else
+ if (accel_mask & MASK_CONTROL)
+ res.append(trans("accel-win-control"));
+ if (accel_mask & MASK_ALT)
+ res.append(trans("accel-win-alt"));
+ if (accel_mask & MASK_SHIFT)
+ res.append(trans("accel-win-shift"));
+#endif
+ return res;
+}
//static
std::string LLKeyboard::stringFromAccelerator( MASK accel_mask, KEY key )
{
@@ -359,41 +403,7 @@ std::string LLKeyboard::stringFromAccelerator( MASK accel_mask, KEY key )
return res;
}
- LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator;
-
- if( trans == NULL )
- {
- LL_ERRS() << "No mKeyStringTranslator" << LL_ENDL;
- return res;
- }
-
- // Append any masks
-#ifdef LL_DARWIN
- // Standard Mac names for modifier keys in menu equivalents
- // We could use the symbol characters, but they only exist in certain fonts.
- if( accel_mask & MASK_CONTROL )
- {
- if ( accel_mask & MASK_MAC_CONTROL )
- {
- res.append( trans("accel-mac-control") );
- }
- else
- {
- res.append( trans("accel-mac-command") ); // Symbol would be "\xE2\x8C\x98"
- }
- }
- if( accel_mask & MASK_ALT )
- res.append( trans("accel-mac-option") ); // Symbol would be "\xE2\x8C\xA5"
- if( accel_mask & MASK_SHIFT )
- res.append( trans("accel-mac-shift") ); // Symbol would be "\xE2\x8C\xA7"
-#else
- if( accel_mask & MASK_CONTROL )
- res.append( trans("accel-win-control") );
- if( accel_mask & MASK_ALT )
- res.append( trans("accel-win-alt") );
- if( accel_mask & MASK_SHIFT )
- res.append( trans("accel-win-shift") );
-#endif
+ res.append(stringFromAccelerator(accel_mask));
std::string key_string = LLKeyboard::stringFromKey(key);
if ((accel_mask & MASK_NORMALKEYS) &&
(key_string[0] == '-' || key_string[0] == '=' || key_string[0] == '+'))