From fec1dcbd7370725d0fbc0294d92142e23e3af218 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 23 Mar 2015 01:10:00 +0100 Subject: [PATCH] Don't send events for already selected radio popup menu items. Selecting an already selected radio menu item didn't generate any events in wxGTK nor in wxMSW with the top level (i.e. attached to a menu bar) menus but did send them for popup menus under MSW. Make the last case consistent with the rest of them and don't send any events in this case neither. Closes #16891. --- docs/changes.txt | 1 + src/msw/menu.cpp | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6e22f28d39..85541a9e5f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -141,6 +141,7 @@ wxMSW: - Fix appearance of checked disabled wxToolBar tools with custom images. - Fix reading of not NUL-terminated strings using wxRegKey (Steffen Olszewski). - Fix unexpected change in MDI children order after showing a file dialog. +- Don't send events for already selected radio popup menu items (Kinaou Hervé). wxOSX/Cocoa: diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 1a1e6e0038..5045253449 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -969,17 +969,23 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_) // update the check item when it's clicked wxMenuItem * const item = FindItem(id); - if ( item && item->IsCheckable() ) + if ( item ) { - item->Toggle(); + if ( (item->GetKind() == wxITEM_RADIO) && item->IsChecked() ) + return true; - // Get the status of the menu item: note that it has been just changed - // by Toggle() above so here we already get the new state of the item. - // - // Also notice that we must pass unsigned id_ and not sign-extended id - // to ::GetMenuState() as this is what it expects. - UINT menuState = ::GetMenuState(GetHmenu(), id_, MF_BYCOMMAND); - checked = (menuState & MF_CHECKED) != 0; + if ( item->IsCheckable() ) + { + item->Toggle(); + + // Get the status of the menu item: note that it has been just changed + // by Toggle() above so here we already get the new state of the item. + // + // Also notice that we must pass unsigned id_ and not sign-extended id + // to ::GetMenuState() as this is what it expects. + UINT menuState = ::GetMenuState(GetHmenu(), id_, MF_BYCOMMAND); + checked = (menuState & MF_CHECKED) != 0; + } } SendEvent(id, checked);