#if wxUSE_ACCEL
#ifndef WX_PRECOMP
+ #include "wx/accel.h"
#include "wx/string.h"
#include "wx/intl.h"
#include "wx/log.h"
- #include "wx/accel.h"
#include "wx/crt.h"
#endif //WX_PRECOMP
+wxAcceleratorTable wxNullAcceleratorTable;
+
// ============================================================================
// wxAcceleratorEntry implementation
// ============================================================================
{
// the parser won't like trailing spaces
wxString label = text;
- label.Trim(true); // the initial \t must be preserved so don't strip leading whitespaces
+ label.Trim(true);
- // check for accelerators: they are given after '\t'
+ // For compatibility with the old wx versions which accepted (and actually
+ // even required) a TAB character in the string passed to this function we
+ // ignore anything up to the first TAB. Notice however that the correct
+ // input consists of just the accelerator itself and nothing else, this is
+ // done for compatibility and compatibility only.
int posTab = label.Find(wxT('\t'));
if ( posTab == wxNOT_FOUND )
- {
- return false;
- }
+ posTab = 0;
+ else
+ posTab++;
// parse the accelerator string
int accelFlags = wxACCEL_NORMAL;
wxString current;
- for ( size_t n = (size_t)posTab + 1; n < label.length(); n++ )
+ for ( size_t n = (size_t)posTab; n < label.length(); n++ )
{
if ( (label[n] == '+') || (label[n] == '-') )
{
accelFlags |= wxACCEL_ALT;
else if ( CompareAccelString(current, wxTRANSLATE("shift")) )
accelFlags |= wxACCEL_SHIFT;
+ else if ( CompareAccelString(current, wxTRANSLATE("rawctrl")) )
+ accelFlags |= wxACCEL_RAW_CTRL;
else // not a recognized modifier name
{
// we may have "Ctrl-+", for example, but we still want to
/* static */
wxAcceleratorEntry *wxAcceleratorEntry::Create(const wxString& str)
{
+ const wxString accelStr = str.AfterFirst('\t');
+ if ( accelStr.empty() )
+ {
+ // It's ok to pass strings not containing any accelerators at all to
+ // this function, wxMenuItem code does it and we should just return
+ // NULL in this case.
+ return NULL;
+ }
+
int flags,
keyCode;
- if ( !ParseAccel(str, &flags, &keyCode) )
+ if ( !ParseAccel(accelStr, &flags, &keyCode) )
return NULL;
return new wxAcceleratorEntry(flags, keyCode);
int flags = GetFlags();
if ( flags & wxACCEL_ALT )
- text += _("Alt-");
+ text += _("Alt+");
if ( flags & wxACCEL_CTRL )
- text += _("Ctrl-");
+ text += _("Ctrl+");
if ( flags & wxACCEL_SHIFT )
- text += _("Shift-");
-
+ text += _("Shift+");
+#if defined(__WXMAC__) || defined(__WXCOCOA__)
+ if ( flags & wxACCEL_RAW_CTRL )
+ text += _("RawCtrl+");
+#endif
+
const int code = GetKeyCode();
if ( code >= WXK_F1 && code <= WXK_F12 )
// must be a simple key
if (
#if !wxUSE_UNICODE
- isascii(code) &&
+ // we can't call wxIsalnum() for non-ASCII characters in ASCII
+ // build as they're only defined for the ASCII range (or EOF)
+ wxIsascii(code) &&
#endif // ANSI
- wxIsalnum(code) )
+ wxIsprint(code) )
{
text << (wxChar)code;
}