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
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user