]> git.saurik.com Git - wxWidgets.git/commitdiff
fix for items without accelerators
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 26 Oct 1999 13:45:29 +0000 (13:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 26 Oct 1999 13:45:29 +0000 (13:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4197 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/menu.cpp
src/gtk1/menu.cpp

index d0b20891bbf5f33feea8877add9c68e3a2f5d359..bc156417a73b20b17898c91deddd6b55aed3ab86 100644 (file)
@@ -810,51 +810,56 @@ static wxString GetHotKey( const wxMenuItem& item )
     // as wxGetAccelFromString() looks for TAB, insert a dummy one here
     wxString label;
     label << wxT('\t') << item.GetHotKey();
-    wxAcceleratorEntry *accel = wxGetAccelFromString(label);
-    if ( accel )
+
+    // but if the hotkey is empty don't do anything
+    if ( label.length() > 1 )
     {
-        int flags = accel->GetFlags();
-        if ( flags & wxACCEL_ALT )
-            hotkey += wxT("<alt>");
-        if ( flags & wxACCEL_CTRL )
-            hotkey += wxT("<control>");
-        if ( flags & wxACCEL_SHIFT )
-            hotkey += wxT("<shift>");
-
-        int code = accel->GetKeyCode();
-        switch ( code )
+        wxAcceleratorEntry *accel = wxGetAccelFromString(label);
+        if ( accel )
         {
-            case WXK_F1:
-            case WXK_F2:
-            case WXK_F3:
-            case WXK_F4:
-            case WXK_F5:
-            case WXK_F6:
-            case WXK_F7:
-            case WXK_F8:
-            case WXK_F9:
-            case WXK_F10:
-            case WXK_F11:
-            case WXK_F12:
-                hotkey << wxT('F') << code = WXK_F1 + 1;
-                break;
-
-            // if there are any other keys wxGetAccelFromString() may return,
-            // we should process them here
-
-            default:
-                if ( wxIsalnum(code) )
-                {
-                    hotkey << (wxChar)code;
-
+            int flags = accel->GetFlags();
+            if ( flags & wxACCEL_ALT )
+                hotkey += wxT("<alt>");
+            if ( flags & wxACCEL_CTRL )
+                hotkey += wxT("<control>");
+            if ( flags & wxACCEL_SHIFT )
+                hotkey += wxT("<shift>");
+
+            int code = accel->GetKeyCode();
+            switch ( code )
+            {
+                case WXK_F1:
+                case WXK_F2:
+                case WXK_F3:
+                case WXK_F4:
+                case WXK_F5:
+                case WXK_F6:
+                case WXK_F7:
+                case WXK_F8:
+                case WXK_F9:
+                case WXK_F10:
+                case WXK_F11:
+                case WXK_F12:
+                    hotkey << wxT('F') << code = WXK_F1 + 1;
                     break;
-                }
 
-                wxFAIL_MSG( wxT("unknown keyboard accel") );
+                // if there are any other keys wxGetAccelFromString() may return,
+                // we should process them here
+
+                default:
+                    if ( wxIsalnum(code) )
+                    {
+                        hotkey << (wxChar)code;
+
+                        break;
+                    }
+
+                    wxFAIL_MSG( wxT("unknown keyboard accel") );
+            }
+
+            delete accel;
         }
     }
-    if (accel)
-        delete accel;
 
     return hotkey;
 }
index d0b20891bbf5f33feea8877add9c68e3a2f5d359..bc156417a73b20b17898c91deddd6b55aed3ab86 100644 (file)
@@ -810,51 +810,56 @@ static wxString GetHotKey( const wxMenuItem& item )
     // as wxGetAccelFromString() looks for TAB, insert a dummy one here
     wxString label;
     label << wxT('\t') << item.GetHotKey();
-    wxAcceleratorEntry *accel = wxGetAccelFromString(label);
-    if ( accel )
+
+    // but if the hotkey is empty don't do anything
+    if ( label.length() > 1 )
     {
-        int flags = accel->GetFlags();
-        if ( flags & wxACCEL_ALT )
-            hotkey += wxT("<alt>");
-        if ( flags & wxACCEL_CTRL )
-            hotkey += wxT("<control>");
-        if ( flags & wxACCEL_SHIFT )
-            hotkey += wxT("<shift>");
-
-        int code = accel->GetKeyCode();
-        switch ( code )
+        wxAcceleratorEntry *accel = wxGetAccelFromString(label);
+        if ( accel )
         {
-            case WXK_F1:
-            case WXK_F2:
-            case WXK_F3:
-            case WXK_F4:
-            case WXK_F5:
-            case WXK_F6:
-            case WXK_F7:
-            case WXK_F8:
-            case WXK_F9:
-            case WXK_F10:
-            case WXK_F11:
-            case WXK_F12:
-                hotkey << wxT('F') << code = WXK_F1 + 1;
-                break;
-
-            // if there are any other keys wxGetAccelFromString() may return,
-            // we should process them here
-
-            default:
-                if ( wxIsalnum(code) )
-                {
-                    hotkey << (wxChar)code;
-
+            int flags = accel->GetFlags();
+            if ( flags & wxACCEL_ALT )
+                hotkey += wxT("<alt>");
+            if ( flags & wxACCEL_CTRL )
+                hotkey += wxT("<control>");
+            if ( flags & wxACCEL_SHIFT )
+                hotkey += wxT("<shift>");
+
+            int code = accel->GetKeyCode();
+            switch ( code )
+            {
+                case WXK_F1:
+                case WXK_F2:
+                case WXK_F3:
+                case WXK_F4:
+                case WXK_F5:
+                case WXK_F6:
+                case WXK_F7:
+                case WXK_F8:
+                case WXK_F9:
+                case WXK_F10:
+                case WXK_F11:
+                case WXK_F12:
+                    hotkey << wxT('F') << code = WXK_F1 + 1;
                     break;
-                }
 
-                wxFAIL_MSG( wxT("unknown keyboard accel") );
+                // if there are any other keys wxGetAccelFromString() may return,
+                // we should process them here
+
+                default:
+                    if ( wxIsalnum(code) )
+                    {
+                        hotkey << (wxChar)code;
+
+                        break;
+                    }
+
+                    wxFAIL_MSG( wxT("unknown keyboard accel") );
+            }
+
+            delete accel;
         }
     }
-    if (accel)
-        delete accel;
 
     return hotkey;
 }