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
// Implementation
WXHWND *GetRadioButtons() const { return m_radioButtons; }
bool ContainsHWND(WXHWND hWnd) const;
// Implementation
WXHWND *GetRadioButtons() const { return m_radioButtons; }
bool ContainsHWND(WXHWND hWnd) const;
+ void SendNotificationEvent();
long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
{
if ( param == BN_CLICKED )
{
{
if ( param == BN_CLICKED )
{
+ int selectedButton = -1;
for ( int i = 0; i < m_noItems; i++ )
{
if ( id == GET_WIN_ID(m_radioButtons[i]) )
{
for ( int i = 0; i < m_noItems; i++ )
{
if ( id == GET_WIN_ID(m_radioButtons[i]) )
{
- 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
if ( !s_wndprocRadioBtn )
s_wndprocRadioBtn = (WXFARPROC)::GetWindowLong(hwndBtn, GWL_WNDPROC);
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__
// No GWL_USERDATA in Win16, so omit this subclassing.
#ifdef __WIN32__
+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
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// window proc for radio buttons
// ---------------------------------------------------------------------------
if ( processed )
{
if ( sel >= 0 && sel < radiobox->Number() )
if ( processed )
{
if ( sel >= 0 && sel < radiobox->Number() )
radiobox->SetSelection(sel);
radiobox->SetSelection(sel);
+
+ // emulate the button click
+ radiobox->SendNotificationEvent();
+ }