Merge branch 'spinbutton-up-down-events' of https://github.com/catalinr/wxWidgets

Fix wxSpinButton events in wxQt.

See https://github.com/wxWidgets/wxWidgets/pull/1232
This commit is contained in:
Vadim Zeitlin
2019-02-22 00:03:04 +01:00

View File

@@ -20,6 +20,7 @@ public:
private: private:
void valueChanged(int value); void valueChanged(int value);
virtual void stepBy(int steps) wxOVERRIDE; // see QAbstractSpinBox::stepBy()
}; };
wxQtSpinButton::wxQtSpinButton( wxWindow *parent, wxSpinButton *handler ) wxQtSpinButton::wxQtSpinButton( wxWindow *parent, wxSpinButton *handler )
@@ -34,12 +35,30 @@ void wxQtSpinButton::valueChanged(int value)
wxSpinButton *handler = GetHandler(); wxSpinButton *handler = GetHandler();
if ( handler ) if ( handler )
{ {
wxCommandEvent event( wxEVT_SPIN, handler->GetId() ); wxSpinEvent event( wxEVT_SPIN, handler->GetId() );
event.SetInt( value ); event.SetInt( value );
EmitEvent( event ); EmitEvent( event );
} }
} }
void wxQtSpinButton::stepBy(int steps)
{
wxSpinButton* const handler = GetHandler();
if ( !handler )
return;
int eventType = steps < 0 ? wxEVT_SPIN_DOWN : wxEVT_SPIN_UP;
wxSpinEvent directionEvent(eventType, handler->GetId());
directionEvent.SetPosition(value());
directionEvent.SetInt(value() + steps * singleStep());
directionEvent.SetEventObject(handler);
if ( !handler->HandleWindowEvent(directionEvent) || directionEvent.IsAllowed() )
{
QSpinBox::stepBy(steps);
}
}
wxSpinButton::wxSpinButton() : wxSpinButton::wxSpinButton() :
m_qtSpinBox(NULL) m_qtSpinBox(NULL)