diff options
Diffstat (limited to 'indra/llui/llmenugl.cpp')
-rw-r--r-- | indra/llui/llmenugl.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 2cae50bd04..5857f49a3e 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -152,6 +152,14 @@ LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const out << LLKeyboard::stringFromKey(mAcceleratorKey); node->createChild("shortcut", TRUE)->setStringValue(out.str()); + +#ifdef LL_DARWIN + // Write in special tag if this key is really a ctrl combination on the Mac + if (mAcceleratorMask & MASK_MAC_CONTROL) + { + node->createChild("useMacCtrl", TRUE)->setBoolValue( TRUE ); + } +#endif // LL_DARWIN } return node; @@ -184,7 +192,7 @@ BOOL LLMenuItemGL::handleKey(KEY key, MASK mask, BOOL called_from_parent) BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask) { - if( mEnabled && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == mAcceleratorMask) ) + if( mEnabled && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) { doIt(); return TRUE; @@ -216,7 +224,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) for (list_it = listp->begin(); list_it != listp->end(); ++list_it) { accelerator = *list_it; - if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == mAcceleratorMask)) + if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == (mAcceleratorMask & MASK_NORMALKEYS))) { // *NOTE: get calling code to throw up warning or route @@ -240,7 +248,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) if (accelerator) { accelerator->mKey = mAcceleratorKey; - accelerator->mMask = mAcceleratorMask; + accelerator->mMask = (mAcceleratorMask & MASK_NORMALKEYS); // accelerator->mName = mLabel; } listp->push_back(accelerator);//addData(accelerator); @@ -264,7 +272,16 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st ) // Standard Mac names for modifier keys in menu equivalents // We could use the symbol characters, but they only exist in certain fonts. if( mAcceleratorMask & MASK_CONTROL ) - st.append( "Cmd-" ); // Symbol would be "\xE2\x8C\x98" + { + if ( mAcceleratorMask & MASK_MAC_CONTROL ) + { + st.append( "Ctrl-" ); + } + else + { + st.append( "Cmd-" ); // Symbol would be "\xE2\x8C\x98" + } + } if( mAcceleratorMask & MASK_ALT ) st.append( "Opt-" ); // Symbol would be "\xE2\x8C\xA5" if( mAcceleratorMask & MASK_SHIFT ) @@ -279,7 +296,7 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st ) #endif LLString keystr = LLKeyboard::stringFromKey( mAcceleratorKey ); - if ((mAcceleratorMask & (MASK_CONTROL|MASK_ALT|MASK_SHIFT)) && + if ((mAcceleratorMask & MASK_NORMALKEYS) && (keystr[0] == '-' || keystr[0] == '=')) { st.append( " " ); @@ -978,7 +995,7 @@ void LLMenuItemCallGL::buildDrawLabel( void ) BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) { - if( (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == mAcceleratorMask) ) + if( (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) { LLPointer<LLEvent> fired_event = new LLEvent(this); fireEvent(fired_event, "on_build"); @@ -1945,10 +1962,23 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory child->hasName(LL_MENU_ITEM_CHECK_GL_TAG)) { MASK mask = 0; + +#ifdef LL_DARWIN + // See if this Mac accelerator should really use the ctrl key and not get mapped to cmd + BOOL useMacCtrl = FALSE; + child->getAttributeBOOL("useMacCtrl", useMacCtrl); +#endif // LL_DARWIN + LLString shortcut; child->getAttributeString("shortcut", shortcut); if (shortcut.find("control") != shortcut.npos) { +#ifdef LL_DARWIN + if ( useMacCtrl ) + { + mask |= MASK_MAC_CONTROL; + } +#endif // LL_DARWIN mask |= MASK_CONTROL; } if (shortcut.find("alt") != shortcut.npos) |