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.cpp69
1 files changed, 68 insertions, 1 deletions
diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp
index f0f618aef1..16cbf815e0 100644
--- a/indra/llwindow/llkeyboard.cpp
+++ b/indra/llwindow/llkeyboard.cpp
@@ -36,7 +36,6 @@
#include "llwindowcallbacks.h"
-
//
// Globals
//
@@ -46,6 +45,8 @@ LLKeyboard *gKeyboard = NULL;
//static
std::map<KEY,std::string> LLKeyboard::sKeysToNames;
std::map<std::string,KEY> LLKeyboard::sNamesToKeys;
+LLKeyStringTranslatorFunc* LLKeyboard::mStringTranslator = NULL; // Used for l10n + PC/Mac/Linux accelerator labeling
+
//
// Class Implementation
@@ -346,6 +347,65 @@ std::string LLKeyboard::stringFromKey(KEY key)
}
+//static
+std::string LLKeyboard::stringFromAccelerator( MASK accel_mask, KEY key )
+{
+ std::string res;
+
+ // break early if this is a silly thing to do.
+ if( KEY_NONE == key )
+ {
+ return res;
+ }
+
+ LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator;
+
+ if( trans == NULL )
+ {
+ llerrs << "No mKeyStringTranslator" << llendl;
+ 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
+ std::string key_string = LLKeyboard::stringFromKey(key);
+ if ((accel_mask & MASK_NORMALKEYS) &&
+ (key_string[0] == '-' || key_string[0] == '=' || key_string[0] == '+'))
+ {
+ res.append( " " );
+ }
+
+ std::string keystr = stringFromKey( key );
+ res.append( keystr );
+
+ return res;
+}
+
//static
BOOL LLKeyboard::maskFromString(const std::string& str, MASK *mask)
@@ -396,3 +456,10 @@ BOOL LLKeyboard::maskFromString(const std::string& str, MASK *mask)
return FALSE;
}
}
+
+
+//static
+void LLKeyboard::setStringTranslatorFunc( LLKeyStringTranslatorFunc *trans_func )
+{
+ mStringTranslator = trans_func;
+}