From 164c67c40fd4c2b9d1ca51abb5f64fa476ef5ad7 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 6 Jan 2009 09:40:34 +0000 Subject: [PATCH] bringing ctrl and cmd accel handling for menus in line with pure key event handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@57852 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/menucmn.cpp | 10 +++++++++- src/mac/carbon/uma.cpp | 15 +++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index ad6dbe1bec..eb9c95f718 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -194,7 +194,11 @@ wxAcceleratorEntry::ParseAccel(const wxString& text, int *flagsOut, int *keyOut) { if ( (label[n] == '+') || (label[n] == '-') ) { + // differentiate between a ctrl that will be translated to cmd on mac + // and an explicit xctrl that will not be translated and remains a ctrl if ( CompareAccelString(current, wxTRANSLATE("ctrl")) ) + accelFlags |= wxACCEL_CMD; + else if ( CompareAccelString(current, wxTRANSLATE("xctrl")) ) accelFlags |= wxACCEL_CTRL; else if ( CompareAccelString(current, wxTRANSLATE("alt")) ) accelFlags |= wxACCEL_ALT; @@ -312,8 +316,12 @@ wxString wxAcceleratorEntry::ToString() const int flags = GetFlags(); if ( flags & wxACCEL_ALT ) text += _("Alt-"); - if ( flags & wxACCEL_CTRL ) + if ( flags & wxACCEL_CMD ) text += _("Ctrl-"); +#ifdef __WXMAC__ + if ( flags & wxACCEL_CTRL ) + text += _("XCtrl-"); +#endif if ( flags & wxACCEL_SHIFT ) text += _("Shift-"); diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index f368bfa5ed..9627ad6121 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -193,7 +193,9 @@ void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEn SInt16 key = entry->GetKeyCode() ; if ( key ) { - bool explicitCommandKey = (entry->GetFlags() & wxACCEL_CTRL); + bool explicitCommandKey = (entry->GetFlags() & wxACCEL_CMD); + if ( !explicitCommandKey ) + modifiers |= kMenuNoCommandModifier ; if (entry->GetFlags() & wxACCEL_ALT) modifiers |= kMenuOptionModifier ; @@ -201,12 +203,14 @@ void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEn if (entry->GetFlags() & wxACCEL_SHIFT) modifiers |= kMenuShiftModifier ; + if (entry->GetFlags() & wxACCEL_CTRL) + modifiers |= kMenuControlModifier ; + + SInt16 glyph = 0 ; SInt16 macKey = key ; if ( key >= WXK_F1 && key <= WXK_F15 ) { - if ( !explicitCommandKey ) - modifiers |= kMenuNoCommandModifier ; // for some reasons this must be 0 right now // everything else leads to just the first function key item @@ -303,11 +307,6 @@ void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEn macKey = toupper( key ) ; break ; } - - // we now allow non command key shortcuts - // remove in case this gives problems - if ( !explicitCommandKey ) - modifiers |= kMenuNoCommandModifier ; } // 1d and 1e have special meaning to SetItemCmd, so