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:
commit
e9813688ad
@ -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 )
|
||||
@ -34,12 +35,30 @@ void wxQtSpinButton::valueChanged(int value)
|
||||
wxSpinButton *handler = GetHandler();
|
||||
if ( handler )
|
||||
{
|
||||
wxCommandEvent event( wxEVT_SPIN, handler->GetId() );
|
||||
wxSpinEvent event( wxEVT_SPIN, handler->GetId() );
|
||||
event.SetInt( value );
|
||||
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() :
|
||||
m_qtSpinBox(NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user