]> git.saurik.com Git - wxWidgets.git/commitdiff
added support for non alphanumeric simple character accelerators
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Mar 2002 12:23:11 +0000 (12:23 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Mar 2002 12:23:11 +0000 (12:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14514 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/menucmn.cpp
src/gtk/menu.cpp
src/gtk1/menu.cpp

index 37e0315ec33537002ee0772f821eb4068fb15167..7b5e0d626a2c702ae24041e00065047e557a9778 100644 (file)
@@ -140,6 +140,7 @@ wxGTK:
 - wxDirDialog now presents the file system in standard Unix way
 - wxButton now honours wxBU_EXACTFIT
 - wxStaticBox now honours wxALIGN_XXX styles
+- added support for non alphanumeric simple character accelerators ('-', '=')
 
 wxHTML:
 
index b9ecb0cf076453a65546bb5a9cec1eadfe1c7e58..1f2b9fcbb7bbd8a255083a51229aff9f385ab780 100644 (file)
@@ -82,11 +82,25 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label)
                 else if ( current == _("shift") )
                     accelFlags |= wxACCEL_SHIFT;
                 else {
-                    wxLogDebug(wxT("Unknown accel modifier: '%s'"),
-                               current.c_str());
+                    // we may have "Ctrl-+", for example, but we still want to
+                    // catch typos like "Crtl-A" so only give the warning if we
+                    // have something before the current '+' or '-', else take
+                    // it as a literal symbol
+                    if ( current.empty() )
+                    {
+                        current += label[n];
+
+                        // skip clearing it below
+                        continue;
+                    }
+                    else
+                    {
+                        wxLogDebug(wxT("Unknown accel modifier: '%s'"),
+                                   current.c_str());
+                    }
                 }
 
-                current.Empty();
+                current.clear();
             }
             else {
                 current += wxTolower(label[n]);
index fd598295af0abbe999c7c72300b31b9279b1c374..d3aee69d38979eb6cbd3e180e042e4d5fdee4591 100644 (file)
@@ -1145,6 +1145,7 @@ int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const
 // ----------------------------------------------------------------------------
 
 #if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
+
 static wxString GetHotKey( const wxMenuItem& item )
 {
     wxString hotkey;
@@ -1178,7 +1179,9 @@ static wxString GetHotKey( const wxMenuItem& item )
                 hotkey << wxT('F') << code - WXK_F1 + 1;
                 break;
                 
-                // GTK seems to use XStringToKeySym here
+                // TODO: we should use gdk_keyval_name() (a.k.a.
+                //       XKeysymToString) here as well as hardcoding the keysym
+                //       names this might be not portable
             case WXK_NUMPAD_INSERT:
                 hotkey << wxT("KP_Insert" );
                 break;
@@ -1192,15 +1195,18 @@ static wxString GetHotKey( const wxMenuItem& item )
                 hotkey << wxT("Delete" );
                 break;
 
-                // if there are any other keys wxGetAccelFromString() may return,
-                // we should process them here
+                // if there are any other keys wxGetAccelFromString() may
+                // return, we should process them here
 
             default:
-                if ( wxIsalnum(code) )
+                if ( code < 127 )
                 {
-                    hotkey << (wxChar)code;
-
-                    break;
+                    gchar *name = gdk_keyval_name((guint)code);
+                    if ( name )
+                    {
+                        hotkey << name;
+                        break;
+                    }
                 }
 
                 wxFAIL_MSG( wxT("unknown keyboard accel") );
@@ -1211,6 +1217,7 @@ static wxString GetHotKey( const wxMenuItem& item )
 
     return hotkey;
 }
+
 #endif // wxUSE_ACCEL
 
 
index fd598295af0abbe999c7c72300b31b9279b1c374..d3aee69d38979eb6cbd3e180e042e4d5fdee4591 100644 (file)
@@ -1145,6 +1145,7 @@ int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const
 // ----------------------------------------------------------------------------
 
 #if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
+
 static wxString GetHotKey( const wxMenuItem& item )
 {
     wxString hotkey;
@@ -1178,7 +1179,9 @@ static wxString GetHotKey( const wxMenuItem& item )
                 hotkey << wxT('F') << code - WXK_F1 + 1;
                 break;
                 
-                // GTK seems to use XStringToKeySym here
+                // TODO: we should use gdk_keyval_name() (a.k.a.
+                //       XKeysymToString) here as well as hardcoding the keysym
+                //       names this might be not portable
             case WXK_NUMPAD_INSERT:
                 hotkey << wxT("KP_Insert" );
                 break;
@@ -1192,15 +1195,18 @@ static wxString GetHotKey( const wxMenuItem& item )
                 hotkey << wxT("Delete" );
                 break;
 
-                // if there are any other keys wxGetAccelFromString() may return,
-                // we should process them here
+                // if there are any other keys wxGetAccelFromString() may
+                // return, we should process them here
 
             default:
-                if ( wxIsalnum(code) )
+                if ( code < 127 )
                 {
-                    hotkey << (wxChar)code;
-
-                    break;
+                    gchar *name = gdk_keyval_name((guint)code);
+                    if ( name )
+                    {
+                        hotkey << name;
+                        break;
+                    }
                 }
 
                 wxFAIL_MSG( wxT("unknown keyboard accel") );
@@ -1211,6 +1217,7 @@ static wxString GetHotKey( const wxMenuItem& item )
 
     return hotkey;
 }
+
 #endif // wxUSE_ACCEL