diff options
| author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-09-19 16:59:23 +0300 | 
|---|---|---|
| committer | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-09-19 16:59:23 +0300 | 
| commit | fc238f6ca06b6fc71ed3bb7c3968f48406bb2c09 (patch) | |
| tree | 47be5753a7bfd5422e24d7d9ade455b2040b04f0 /indra/llwindow | |
| parent | 4d7c106a6108ff88b5b5211addc5e8b7506fb1b1 (diff) | |
SL-6109 Extended Key-to-string functionality
Diffstat (limited to 'indra/llwindow')
| -rw-r--r-- | indra/llwindow/llkeyboard.cpp | 77 | ||||
| -rw-r--r-- | indra/llwindow/llkeyboard.h | 14 | 
2 files changed, 45 insertions, 46 deletions
| diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index f6f6c3931c..8e75325859 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -347,7 +347,48 @@ std::string LLKeyboard::stringFromKey(KEY key)  	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 +400,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] == '+')) diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 6f2dc87317..f6404164e7 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -38,10 +38,10 @@ enum EKeystate  {  	KEYSTATE_DOWN,  	KEYSTATE_LEVEL, -	KEYSTATE_UP  +	KEYSTATE_UP  }; -typedef boost::function<void(EKeystate keystate)> LLKeyFunc; +typedef boost::function<bool(EKeystate keystate)> LLKeyFunc;  typedef std::string (LLKeyStringTranslatorFunc)(const char *label);  enum EKeyboardInsertMode @@ -50,15 +50,6 @@ enum EKeyboardInsertMode  	LL_KIM_OVERWRITE  }; -class LLKeyBinding -{ -public: -	KEY				mKey; -	MASK			mMask; -// 	const char		*mName; // unused -	LLKeyFunc		mFunction; -}; -  class LLWindowCallbacks;  class LLKeyboard @@ -104,6 +95,7 @@ public:  	static BOOL		maskFromString(const std::string& str, MASK *mask);		// False on failure  	static BOOL		keyFromString(const std::string& str, KEY *key);			// False on failure  	static std::string stringFromKey(KEY key); +	static std::string stringFromAccelerator( MASK accel_mask ); // separated for convinience, returns with "+": "Shift+" or "Shift+Alt+"...  	static std::string stringFromAccelerator( MASK accel_mask, KEY key );  	void setCallbacks(LLWindowCallbacks *cbs) { mCallbacks = cbs; } | 
