added support for non alphanumeric simple character accelerators
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14514 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -140,6 +140,7 @@ wxGTK:
|
|||||||
- wxDirDialog now presents the file system in standard Unix way
|
- wxDirDialog now presents the file system in standard Unix way
|
||||||
- wxButton now honours wxBU_EXACTFIT
|
- wxButton now honours wxBU_EXACTFIT
|
||||||
- wxStaticBox now honours wxALIGN_XXX styles
|
- wxStaticBox now honours wxALIGN_XXX styles
|
||||||
|
- added support for non alphanumeric simple character accelerators ('-', '=')
|
||||||
|
|
||||||
wxHTML:
|
wxHTML:
|
||||||
|
|
||||||
|
@@ -82,11 +82,25 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label)
|
|||||||
else if ( current == _("shift") )
|
else if ( current == _("shift") )
|
||||||
accelFlags |= wxACCEL_SHIFT;
|
accelFlags |= wxACCEL_SHIFT;
|
||||||
else {
|
else {
|
||||||
wxLogDebug(wxT("Unknown accel modifier: '%s'"),
|
// we may have "Ctrl-+", for example, but we still want to
|
||||||
current.c_str());
|
// 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 {
|
else {
|
||||||
current += wxTolower(label[n]);
|
current += wxTolower(label[n]);
|
||||||
|
@@ -1145,6 +1145,7 @@ int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
|
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
|
||||||
|
|
||||||
static wxString GetHotKey( const wxMenuItem& item )
|
static wxString GetHotKey( const wxMenuItem& item )
|
||||||
{
|
{
|
||||||
wxString hotkey;
|
wxString hotkey;
|
||||||
@@ -1178,7 +1179,9 @@ static wxString GetHotKey( const wxMenuItem& item )
|
|||||||
hotkey << wxT('F') << code - WXK_F1 + 1;
|
hotkey << wxT('F') << code - WXK_F1 + 1;
|
||||||
break;
|
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:
|
case WXK_NUMPAD_INSERT:
|
||||||
hotkey << wxT("KP_Insert" );
|
hotkey << wxT("KP_Insert" );
|
||||||
break;
|
break;
|
||||||
@@ -1192,15 +1195,18 @@ static wxString GetHotKey( const wxMenuItem& item )
|
|||||||
hotkey << wxT("Delete" );
|
hotkey << wxT("Delete" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// if there are any other keys wxGetAccelFromString() may return,
|
// if there are any other keys wxGetAccelFromString() may
|
||||||
// we should process them here
|
// return, we should process them here
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if ( wxIsalnum(code) )
|
if ( code < 127 )
|
||||||
{
|
{
|
||||||
hotkey << (wxChar)code;
|
gchar *name = gdk_keyval_name((guint)code);
|
||||||
|
if ( name )
|
||||||
break;
|
{
|
||||||
|
hotkey << name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFAIL_MSG( wxT("unknown keyboard accel") );
|
wxFAIL_MSG( wxT("unknown keyboard accel") );
|
||||||
@@ -1211,6 +1217,7 @@ static wxString GetHotKey( const wxMenuItem& item )
|
|||||||
|
|
||||||
return hotkey;
|
return hotkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1145,6 +1145,7 @@ int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
|
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
|
||||||
|
|
||||||
static wxString GetHotKey( const wxMenuItem& item )
|
static wxString GetHotKey( const wxMenuItem& item )
|
||||||
{
|
{
|
||||||
wxString hotkey;
|
wxString hotkey;
|
||||||
@@ -1178,7 +1179,9 @@ static wxString GetHotKey( const wxMenuItem& item )
|
|||||||
hotkey << wxT('F') << code - WXK_F1 + 1;
|
hotkey << wxT('F') << code - WXK_F1 + 1;
|
||||||
break;
|
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:
|
case WXK_NUMPAD_INSERT:
|
||||||
hotkey << wxT("KP_Insert" );
|
hotkey << wxT("KP_Insert" );
|
||||||
break;
|
break;
|
||||||
@@ -1192,15 +1195,18 @@ static wxString GetHotKey( const wxMenuItem& item )
|
|||||||
hotkey << wxT("Delete" );
|
hotkey << wxT("Delete" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// if there are any other keys wxGetAccelFromString() may return,
|
// if there are any other keys wxGetAccelFromString() may
|
||||||
// we should process them here
|
// return, we should process them here
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if ( wxIsalnum(code) )
|
if ( code < 127 )
|
||||||
{
|
{
|
||||||
hotkey << (wxChar)code;
|
gchar *name = gdk_keyval_name((guint)code);
|
||||||
|
if ( name )
|
||||||
break;
|
{
|
||||||
|
hotkey << name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFAIL_MSG( wxT("unknown keyboard accel") );
|
wxFAIL_MSG( wxT("unknown keyboard accel") );
|
||||||
@@ -1211,6 +1217,7 @@ static wxString GetHotKey( const wxMenuItem& item )
|
|||||||
|
|
||||||
return hotkey;
|
return hotkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user