Support accelerator keys in wxMenuItem::SetItemLabel()

Closes https://github.com/wxWidgets/wxWidgets/pull/1544
This commit is contained in:
Liam Treacy
2019-09-10 13:42:29 +01:00
committed by Vadim Zeitlin
parent 8c2b9423c2
commit a6efd027da

View File

@@ -51,6 +51,20 @@ void wxMenuItem::SetItemLabel( const wxString &label )
{ {
wxMenuItemBase::SetItemLabel( label ); wxMenuItemBase::SetItemLabel( label );
#if wxUSE_ACCEL
QString qlabel = wxQtConvertString( label );
int index = qlabel.lastIndexOf( QChar( '\t' ) );
if ( index != -1 )
{
QList<QKeySequence> shortcuts = m_qtAction->shortcuts();
QString shortcut_key = qlabel.remove( 0, index+1 );
shortcuts.append( QKeySequence( shortcut_key ) );
m_qtAction->setShortcuts( shortcuts );
}
#endif // wxUSE_ACCEL
m_qtAction->setText( wxQtConvertString( label )); m_qtAction->setText( wxQtConvertString( label ));
} }