Generate events when wxRadioButton is checked under wxQt
Closes https://github.com/wxWidgets/wxWidgets/pull/1210
This commit is contained in:
committed by
Vadim Zeitlin
parent
36fc9b3e5a
commit
f930bd6740
@@ -10,9 +10,32 @@
|
||||
|
||||
#include "wx/radiobut.h"
|
||||
#include "wx/qt/private/converter.h"
|
||||
#include "wx/qt/private/winevent.h"
|
||||
|
||||
#include <QtWidgets/QRadioButton>
|
||||
|
||||
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 );
|
||||
|
Reference in New Issue
Block a user