diff --git a/docs/changes.txt b/docs/changes.txt index 396845dd50..fa82b4feaf 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -20,6 +20,7 @@ wxMSW: - Separators are now correctly shown in the toolbars under Windows XP - Fixed multiline tooltips handling. - Fixed wxSlider::GetSelEnd() (Atilim Cetin) +- Fixed accelerators of menu items added to already attached submenus wxUniv: diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index ddc8094612..2364401560 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -305,6 +305,16 @@ void wxMenu::UpdateAccel(wxMenuItem *item) } else if ( !item->IsSeparator() ) { + // recurse upwards: we should only modify m_accels of the top level + // menus, not of the submenus as wxMenuBar doesn't look at them + // (alternative and arguable cleaner solution would be to recurse + // downwards in GetAccelCount() and CopyAccels()) + if ( GetParent() ) + { + GetParent()->UpdateAccel(item); + return; + } + // find the (new) accel for this item wxAcceleratorEntry *accel = wxGetAccelFromString(item->GetText()); if ( accel )