From 8bf45ed12a5c40871bf56e585d5a32fae84bde0d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 17 Dec 1998 20:24:44 +0000 Subject: [PATCH] The checkbox doesn't eat the first "toggled" event if SetValue(FALSE) was called any more. Added 2 lines to the controls sample to demonstrate it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/controls/controls.cpp | 2 ++ src/gtk/checkbox.cpp | 5 +++++ src/gtk1/checkbox.cpp | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index b74629851c..d8a9805a4f 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -315,6 +315,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); button->SetForegroundColour( "red" ); m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); + m_checkbox->SetValue(FALSE); m_notebook->AddPage(panel, "wxList", FALSE, Image_List); panel = new wxPanel(m_notebook); @@ -517,6 +518,7 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) { case ID_LISTBOX_ENABLE: { + m_text->WriteText("Checkbox clicked.\n"); m_listbox->Enable( event.GetInt() == 0 ); break; } diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index daafd5f43f..9d594ca495 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -97,6 +97,11 @@ void wxCheckBox::SetValue( bool state ) { wxCHECK_RET( m_widget != NULL, "invalid checkbox" ); + if ( state == GetValue() ) + return; + + // for compatibility with wxMSW don't send notification when the check box + // state is changed programmatically m_blockFirstEvent = TRUE; gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), state ); diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index daafd5f43f..9d594ca495 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -97,6 +97,11 @@ void wxCheckBox::SetValue( bool state ) { wxCHECK_RET( m_widget != NULL, "invalid checkbox" ); + if ( state == GetValue() ) + return; + + // for compatibility with wxMSW don't send notification when the check box + // state is changed programmatically m_blockFirstEvent = TRUE; gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), state ); -- 2.45.2