From 900099d6444920d2f0d83ceed0b5e011253a4423 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Jun 2014 01:00:27 +0000 Subject: [PATCH] Fix appearance of custom drawn wxToggleButton in wxMSW. Ensure that the owner-drawn toggle buttons are drawn in the pressed state when they are pressed, even if they are also selected or under mouse. Closes #11665. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/anybutton.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index 78ec983ef1..0c1439f32e 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -832,7 +832,12 @@ wxAnyButton::State GetButtonState(wxAnyButton *btn, UINT state) if ( state & ODS_DISABLED ) return wxAnyButton::State_Disabled; - if ( state & ODS_SELECTED ) + // We need to check for the pressed state of the button itself before the + // other checks because even if it is selected or current, it it still + // pressed first and foremost. + const wxAnyButton::State btnState = btn->GetNormalState(); + + if ( btnState == wxAnyButton::State_Pressed || state & ODS_SELECTED ) return wxAnyButton::State_Pressed; if ( btn->HasCapture() || btn->IsMouseInWindow() ) @@ -841,7 +846,7 @@ wxAnyButton::State GetButtonState(wxAnyButton *btn, UINT state) if ( state & ODS_FOCUS ) return wxAnyButton::State_Focused; - return btn->GetNormalState(); + return btnState; } void DrawButtonText(HDC hdc,