From: Vadim Zeitlin Date: Sat, 17 Apr 1999 20:29:40 +0000 (+0000) Subject: radiobox now sends notification messages when the selection is changed from X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9a5ccab4315dc06b4b56a57c39fbc35b21f5a9d5 radiobox now sends notification messages when the selection is changed from keyboard, but doesn't send them when the selection does not change (when the already selected button is clicked with the mouse) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index caab028ae7..db7ad5f524 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -90,6 +90,7 @@ public: // Implementation WXHWND *GetRadioButtons() const { return m_radioButtons; } bool ContainsHWND(WXHWND hWnd) const; + void SendNotificationEvent(); long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index eff9d9a74b..5d237df03d 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -105,24 +105,27 @@ bool wxRadioBox::MSWCommand(WXUINT param, WXWORD id) { if ( param == BN_CLICKED ) { - m_selectedButton = -1; + int selectedButton = -1; for ( int i = 0; i < m_noItems; i++ ) { if ( id == GET_WIN_ID(m_radioButtons[i]) ) { - m_selectedButton = i; + selectedButton = i; break; } } - wxASSERT_MSG( m_selectedButton != -1, "click from alien button?" ); + wxASSERT_MSG( selectedButton != -1, "click from alien button?" ); - wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); - event.SetInt( m_selectedButton ); - event.SetEventObject( this ); - ProcessCommand(event); + if ( selectedButton != m_selectedButton ) + { + m_selectedButton = selectedButton; + + SendNotificationEvent(); + } + //else: don't generate events when the selection doesn't change return TRUE; } @@ -708,7 +711,6 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn) if ( !s_wndprocRadioBtn ) s_wndprocRadioBtn = (WXFARPROC)::GetWindowLong(hwndBtn, GWL_WNDPROC); -// s_wndprocRadioBtn = (WNDPROC)::GetWindowLong(hwndBtn, GWL_WNDPROC); // No GWL_USERDATA in Win16, so omit this subclassing. #ifdef __WIN32__ @@ -717,6 +719,14 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn) #endif } +void wxRadioBox::SendNotificationEvent() +{ + wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); + event.SetInt( m_selectedButton ); + event.SetEventObject( this ); + ProcessCommand(event); +} + // --------------------------------------------------------------------------- // window proc for radio buttons // --------------------------------------------------------------------------- @@ -777,7 +787,12 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd, if ( processed ) { if ( sel >= 0 && sel < radiobox->Number() ) + { radiobox->SetSelection(sel); + + // emulate the button click + radiobox->SendNotificationEvent(); + } } }