From d4b29b3bcc66d2a1400ba06af0c9fcd4c06f00fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Wed, 20 Feb 2019 15:39:03 +0200 Subject: [PATCH] Add support for wxEVT_SPIN_[UP|DOWN] events --- src/qt/spinbutt.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/qt/spinbutt.cpp b/src/qt/spinbutt.cpp index 688649461c..df62c3ac1e 100644 --- a/src/qt/spinbutt.cpp +++ b/src/qt/spinbutt.cpp @@ -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)