From f930bd6740393b28e91e3d6fc51db4a7c55f3167 Mon Sep 17 00:00:00 2001 From: ffa-benarmstrong <46780196+ffa-benarmstrong@users.noreply.github.com> Date: Fri, 1 Feb 2019 09:27:53 +0000 Subject: [PATCH] Generate events when wxRadioButton is checked under wxQt Closes https://github.com/wxWidgets/wxWidgets/pull/1210 --- src/qt/radiobut.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qt/radiobut.cpp b/src/qt/radiobut.cpp index 1a389997da..57d71bb95b 100644 --- a/src/qt/radiobut.cpp +++ b/src/qt/radiobut.cpp @@ -10,9 +10,32 @@ #include "wx/radiobut.h" #include "wx/qt/private/converter.h" +#include "wx/qt/private/winevent.h" #include +class wxQtRadioButton : public wxQtEventSignalHandler< QRadioButton, wxRadioButton > +{ +public: + wxQtRadioButton( wxWindow *parent, wxRadioButton *handler ) : + wxQtEventSignalHandler< QRadioButton, wxRadioButton >(parent, handler) + + { + connect(this, &QRadioButton::clicked, this, &wxQtRadioButton::OnClicked); + } + + void OnClicked(bool checked) + { + wxRadioButton* handler = GetHandler(); + if ( handler == NULL ) + return; + + wxCommandEvent event(wxEVT_RADIOBUTTON, handler->GetId()); + event.SetInt(checked ? 1 : 0); + EmitEvent(event); + } +}; + wxRadioButton::wxRadioButton() : m_qtRadioButton(NULL) { @@ -39,7 +62,7 @@ bool wxRadioButton::Create( wxWindow *parent, const wxValidator& validator, const wxString& name) { - m_qtRadioButton = new QRadioButton( parent->GetHandle() ); + m_qtRadioButton = new wxQtRadioButton( parent, this ); m_qtRadioButton->setText( wxQtConvertString( label )); return QtCreateControl( parent, id, pos, size, style, validator, name );