From: Vadim Zeitlin Date: Sat, 16 Jul 2005 22:29:47 +0000 (+0000) Subject: fixed handling of the accelerators of menu items added to already attached submenus X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/99f0dc688742156982e526639d17df4cb9003588?ds=sidebyside fixed handling of the accelerators of menu items added to already attached submenus git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- 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 )