Fix wxToggleButton image when state is changed programmatically

See #18779
This commit is contained in:
Paul Cornett 2020-06-02 12:16:57 -07:00
parent cbe21c0cc9
commit d0ed90075c
2 changed files with 4 additions and 3 deletions

View File

@ -45,15 +45,15 @@ protected:
virtual void DoSetBitmap(const wxBitmap& bitmap, State which) wxOVERRIDE; virtual void DoSetBitmap(const wxBitmap& bitmap, State which) wxOVERRIDE;
virtual void DoSetBitmapPosition(wxDirection dir) wxOVERRIDE; virtual void DoSetBitmapPosition(wxDirection dir) wxOVERRIDE;
// update the bitmap to correspond to the current button state
void GTKUpdateBitmap();
private: private:
typedef wxAnyButtonBase base_type; typedef wxAnyButtonBase base_type;
// focus event handler: calls GTKUpdateBitmap() // focus event handler: calls GTKUpdateBitmap()
void GTKOnFocus(wxFocusEvent& event); void GTKOnFocus(wxFocusEvent& event);
// update the bitmap to correspond to the current button state
void GTKUpdateBitmap();
// return the state whose bitmap is being currently shown (so this is // return the state whose bitmap is being currently shown (so this is
// different from the real current state, e.g. it could be State_Normal // different from the real current state, e.g. it could be State_Normal
// even if the button is pressed if no button was set for State_Pressed) // even if the button is pressed if no button was set for State_Pressed)

View File

@ -148,6 +148,7 @@ void wxToggleButton::SetValue(bool state)
wxGtkEventsDisabler<wxToggleButton> noEvents(this); wxGtkEventsDisabler<wxToggleButton> noEvents(this);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), state); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), state);
GTKUpdateBitmap();
} }
// bool GetValue() const // bool GetValue() const