Add support for wxEVT_SPIN_[UP|DOWN] events

This commit is contained in:
Cătălin Răceanu
2019-02-20 15:39:03 +02:00
parent dd56499fe9
commit d4b29b3bcc

View File

@@ -20,6 +20,7 @@ public:
private:
void valueChanged(int value);
virtual void stepBy(int steps) wxOVERRIDE; // see QAbstractSpinBox::stepBy()
};
wxQtSpinButton::wxQtSpinButton( wxWindow *parent, wxSpinButton *handler )
@@ -40,6 +41,26 @@ void wxQtSpinButton::valueChanged(int value)
}
}
void wxQtSpinButton::stepBy(int steps)
{
wxSpinButton* 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);
handler->HandleWindowEvent(directionEvent); // should return value be checked here?
if ( directionEvent.IsAllowed() )
{
QSpinBox::stepBy(steps);
}
}
wxSpinButton::wxSpinButton() :
m_qtSpinBox(NULL)