Fix wxCheckBox::SetValue() when in undetermined state with GTK

State becomes determined when SetValue() is called.
See #24074
This commit is contained in:
Paul Cornett 2023-11-20 08:50:05 -08:00
parent f587ef7c88
commit edd1d758de
2 changed files with 8 additions and 2 deletions

View file

@ -191,11 +191,14 @@ void wxCheckBox::SetValue( bool state )
{
wxCHECK_RET( m_widgetCheckbox != nullptr, wxT("invalid checkbox") );
if (state == GetValue())
GtkToggleButton* tglbtn = GTK_TOGGLE_BUTTON(m_widgetCheckbox);
if (state == GetValue() && !gtk_toggle_button_get_inconsistent(tglbtn))
return;
wxGtkEventsDisabler<wxCheckBox> noEvents(this);
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(m_widgetCheckbox), state );
gtk_toggle_button_set_active(tglbtn, state);
gtk_toggle_button_set_inconsistent(tglbtn, false);
}
bool wxCheckBox::GetValue() const

View file

@ -138,6 +138,9 @@ void CheckBoxTestCase::ThirdStateUser()
m_check->Set3StateValue(wxCHK_UNDETERMINED);
CPPUNIT_ASSERT_EQUAL(wxCHK_UNDETERMINED, m_check->Get3StateValue());
m_check->SetValue(true);
CPPUNIT_ASSERT_EQUAL(wxCHK_CHECKED, m_check->Get3StateValue());
}
void CheckBoxTestCase::InvalidStyles()