X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7e0564433971698eadff8b232315e2fa75c26bf7..6ad68ad8c829a59953913ae034e63ed689562c82:/src/univ/control.cpp diff --git a/src/univ/control.cpp b/src/univ/control.cpp index 67cadcb96f..8e2a06e9de 100644 --- a/src/univ/control.cpp +++ b/src/univ/control.cpp @@ -93,17 +93,19 @@ int wxControl::FindAccelIndex(const wxString& label, wxString *labelOnly) } int indexAccel = -1; - for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ ) + for ( wxString::const_iterator pc = label.begin(); pc != label.end(); ++pc ) { if ( *pc == MNEMONIC_PREFIX ) { - pc++; // skip it - if ( *pc != MNEMONIC_PREFIX ) + ++pc; // skip it + if ( pc == label.end() ) + break; + else if ( *pc != MNEMONIC_PREFIX ) { if ( indexAccel == -1 ) { // remember it (-1 is for MNEMONIC_PREFIX itself - indexAccel = pc - label.c_str() - 1; + indexAccel = pc - label.begin() - 1; } else { @@ -122,6 +124,14 @@ int wxControl::FindAccelIndex(const wxString& label, wxString *labelOnly) } void wxControl::SetLabel(const wxString& label) +{ + // save original label + wxControlBase::SetLabel(label); + + UnivDoSetLabel(label); +} + +void wxControl::UnivDoSetLabel(const wxString& label) { wxString labelOld = m_label; m_indexAccel = FindAccelIndex(label, &m_label); @@ -132,9 +142,4 @@ void wxControl::SetLabel(const wxString& label) } } -wxString wxControl::GetLabel() const -{ - return m_label; -} - #endif // wxUSE_CONTROLS