aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llmenugl.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/llui/llmenugl.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/llui/llmenugl.cpp')
-rw-r--r--linden/indra/llui/llmenugl.cpp52
1 files changed, 44 insertions, 8 deletions
diff --git a/linden/indra/llui/llmenugl.cpp b/linden/indra/llui/llmenugl.cpp
index 9530f26..b0d2d9f 100644
--- a/linden/indra/llui/llmenugl.cpp
+++ b/linden/indra/llui/llmenugl.cpp
@@ -172,6 +172,14 @@ LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const
172 out << LLKeyboard::stringFromKey(mAcceleratorKey); 172 out << LLKeyboard::stringFromKey(mAcceleratorKey);
173 173
174 node->createChild("shortcut", TRUE)->setStringValue(out.str()); 174 node->createChild("shortcut", TRUE)->setStringValue(out.str());
175
176#ifdef LL_DARWIN
177 // Write in special tag if this key is really a ctrl combination on the Mac
178 if (mAcceleratorMask & MASK_MAC_CONTROL)
179 {
180 node->createChild("useMacCtrl", TRUE)->setBoolValue( TRUE );
181 }
182#endif // LL_DARWIN
175 } 183 }
176 184
177 return node; 185 return node;
@@ -204,7 +212,7 @@ BOOL LLMenuItemGL::handleKey(KEY key, MASK mask, BOOL called_from_parent)
204 212
205BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask) 213BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask)
206{ 214{
207 if( mEnabled && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == mAcceleratorMask) ) 215 if( mEnabled && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) )
208 { 216 {
209 doIt(); 217 doIt();
210 return TRUE; 218 return TRUE;
@@ -236,7 +244,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp)
236 for (list_it = listp->begin(); list_it != listp->end(); ++list_it) 244 for (list_it = listp->begin(); list_it != listp->end(); ++list_it)
237 { 245 {
238 accelerator = *list_it; 246 accelerator = *list_it;
239 if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == mAcceleratorMask)) 247 if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == (mAcceleratorMask & MASK_NORMALKEYS)))
240 { 248 {
241 249
242 // *NOTE: get calling code to throw up warning or route 250 // *NOTE: get calling code to throw up warning or route
@@ -260,7 +268,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp)
260 if (accelerator) 268 if (accelerator)
261 { 269 {
262 accelerator->mKey = mAcceleratorKey; 270 accelerator->mKey = mAcceleratorKey;
263 accelerator->mMask = mAcceleratorMask; 271 accelerator->mMask = (mAcceleratorMask & MASK_NORMALKEYS);
264// accelerator->mName = mLabel; 272// accelerator->mName = mLabel;
265 } 273 }
266 listp->push_back(accelerator);//addData(accelerator); 274 listp->push_back(accelerator);//addData(accelerator);
@@ -284,7 +292,16 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st )
284 // Standard Mac names for modifier keys in menu equivalents 292 // Standard Mac names for modifier keys in menu equivalents
285 // We could use the symbol characters, but they only exist in certain fonts. 293 // We could use the symbol characters, but they only exist in certain fonts.
286 if( mAcceleratorMask & MASK_CONTROL ) 294 if( mAcceleratorMask & MASK_CONTROL )
287 st.append( "Cmd-" ); // Symbol would be "\xE2\x8C\x98" 295 {
296 if ( mAcceleratorMask & MASK_MAC_CONTROL )
297 {
298 st.append( "Ctrl-" );
299 }
300 else
301 {
302 st.append( "Cmd-" ); // Symbol would be "\xE2\x8C\x98"
303 }
304 }
288 if( mAcceleratorMask & MASK_ALT ) 305 if( mAcceleratorMask & MASK_ALT )
289 st.append( "Opt-" ); // Symbol would be "\xE2\x8C\xA5" 306 st.append( "Opt-" ); // Symbol would be "\xE2\x8C\xA5"
290 if( mAcceleratorMask & MASK_SHIFT ) 307 if( mAcceleratorMask & MASK_SHIFT )
@@ -299,7 +316,7 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st )
299#endif 316#endif
300 317
301 LLString keystr = LLKeyboard::stringFromKey( mAcceleratorKey ); 318 LLString keystr = LLKeyboard::stringFromKey( mAcceleratorKey );
302 if ((mAcceleratorMask & (MASK_CONTROL|MASK_ALT|MASK_SHIFT)) && 319 if ((mAcceleratorMask & MASK_NORMALKEYS) &&
303 (keystr[0] == '-' || keystr[0] == '=')) 320 (keystr[0] == '-' || keystr[0] == '='))
304 { 321 {
305 st.append( " " ); 322 st.append( " " );
@@ -998,7 +1015,7 @@ void LLMenuItemCallGL::buildDrawLabel( void )
998 1015
999BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) 1016BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask )
1000{ 1017{
1001 if( (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == mAcceleratorMask) ) 1018 if( (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) )
1002 { 1019 {
1003 LLPointer<LLEvent> fired_event = new LLEvent(this); 1020 LLPointer<LLEvent> fired_event = new LLEvent(this);
1004 fireEvent(fired_event, "on_build"); 1021 fireEvent(fired_event, "on_build");
@@ -1394,9 +1411,9 @@ void LLMenuItemBranchGL::updateBranchParent(LLView* parentp)
1394 } 1411 }
1395} 1412}
1396 1413
1397void LLMenuItemBranchGL::onVisibilityChange( BOOL curVisibilityIn ) 1414void LLMenuItemBranchGL::onVisibilityChange( BOOL new_visibility )
1398{ 1415{
1399 if (curVisibilityIn == FALSE && mBranch->getVisible() && !mBranch->getTornOff()) 1416 if (new_visibility == FALSE && !mBranch->getTornOff())
1400 { 1417 {
1401 mBranch->setVisible(FALSE); 1418 mBranch->setVisible(FALSE);
1402 } 1419 }
@@ -1965,10 +1982,23 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory
1965 child->hasName(LL_MENU_ITEM_CHECK_GL_TAG)) 1982 child->hasName(LL_MENU_ITEM_CHECK_GL_TAG))
1966 { 1983 {
1967 MASK mask = 0; 1984 MASK mask = 0;
1985
1986#ifdef LL_DARWIN
1987 // See if this Mac accelerator should really use the ctrl key and not get mapped to cmd
1988 BOOL useMacCtrl = FALSE;
1989 child->getAttributeBOOL("useMacCtrl", useMacCtrl);
1990#endif // LL_DARWIN
1991
1968 LLString shortcut; 1992 LLString shortcut;
1969 child->getAttributeString("shortcut", shortcut); 1993 child->getAttributeString("shortcut", shortcut);
1970 if (shortcut.find("control") != shortcut.npos) 1994 if (shortcut.find("control") != shortcut.npos)
1971 { 1995 {
1996#ifdef LL_DARWIN
1997 if ( useMacCtrl )
1998 {
1999 mask |= MASK_MAC_CONTROL;
2000 }
2001#endif // LL_DARWIN
1972 mask |= MASK_CONTROL; 2002 mask |= MASK_CONTROL;
1973 } 2003 }
1974 if (shortcut.find("alt") != shortcut.npos) 2004 if (shortcut.find("alt") != shortcut.npos)
@@ -2935,6 +2965,12 @@ BOOL LLMenuGL::handleKey( KEY key, MASK mask, BOOL called_from_parent )
2935 2965
2936BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask) 2966BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask)
2937{ 2967{
2968 // don't handle if not enabled
2969 if(!mEnabled)
2970 {
2971 return FALSE;
2972 }
2973
2938 // Pass down even if not visible 2974 // Pass down even if not visible
2939 item_list_t::iterator item_iter; 2975 item_list_t::iterator item_iter;
2940 for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) 2976 for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter)