From 705dd80af197a46091ac3996f9994242763609d9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Mar 2002 14:09:55 +0000 Subject: [PATCH] don't send the events for the radio menu items being unchecked git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/menu.cpp | 24 ++++++++++++++---------- src/gtk1/menu.cpp | 24 ++++++++++++++---------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 9f0f188abe..277353786d 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -621,21 +621,25 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) if (item->IsCheckable()) { - bool isReallyChecked = item->IsChecked(); - if ( item->wxMenuItemBase::IsChecked() == isReallyChecked ) + bool isReallyChecked = item->IsChecked(), + isInternallyChecked = item->wxMenuItemBase::IsChecked(); + + // ensure that the internal state is always consistent with what is + // shown on the screen + item->wxMenuItemBase::Check(isReallyChecked); + + // we must not report the events for the radio button going up nor the + // events resulting from the calls to wxMenuItem::Check() + if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) || + (isInternallyChecked == isReallyChecked) ) { - /* the menu item has been checked by calling wxMenuItem->Check() */ return; } - else - { - /* the user pressed on the menu item -> report and make consistent - * again */ - item->wxMenuItemBase::Check(isReallyChecked); - } + + // the user pressed on the menu item: report the event below } - menu->SendEvent(item->GetId(), item->IsCheckable() ? item->IsChecked() : -1); + menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1); } //----------------------------------------------------------------------------- diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 9f0f188abe..277353786d 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -621,21 +621,25 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) if (item->IsCheckable()) { - bool isReallyChecked = item->IsChecked(); - if ( item->wxMenuItemBase::IsChecked() == isReallyChecked ) + bool isReallyChecked = item->IsChecked(), + isInternallyChecked = item->wxMenuItemBase::IsChecked(); + + // ensure that the internal state is always consistent with what is + // shown on the screen + item->wxMenuItemBase::Check(isReallyChecked); + + // we must not report the events for the radio button going up nor the + // events resulting from the calls to wxMenuItem::Check() + if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) || + (isInternallyChecked == isReallyChecked) ) { - /* the menu item has been checked by calling wxMenuItem->Check() */ return; } - else - { - /* the user pressed on the menu item -> report and make consistent - * again */ - item->wxMenuItemBase::Check(isReallyChecked); - } + + // the user pressed on the menu item: report the event below } - menu->SendEvent(item->GetId(), item->IsCheckable() ? item->IsChecked() : -1); + menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1); } //----------------------------------------------------------------------------- -- 2.45.2