diff --git a/interface/wx/spinbutt.h b/interface/wx/spinbutt.h index 94d304b9a5..7acf76a5bb 100644 --- a/interface/wx/spinbutt.h +++ b/interface/wx/spinbutt.h @@ -78,11 +78,13 @@ public: @beginEventEmissionTable{wxSpinEvent} @event{EVT_SPIN(id, func)} - Generated whenever an arrow is pressed. + Generated whenever pressing an arrow changed the spin button value. @event{EVT_SPIN_UP(id, func)} - Generated when left/up arrow is pressed. + Generated whenever pressing left/up arrow changed the spin button + value. @event{EVT_SPIN_DOWN(id, func)} - Generated when right/down arrow is pressed. + Generated whenever pressing right/down arrow changed the spin + button value. @endEventTable Note that if you handle both SPIN and UP or DOWN events, you will be notified diff --git a/src/osx/spinbutt_osx.cpp b/src/osx/spinbutt_osx.cpp index 16732ab9a4..306576705b 100644 --- a/src/osx/spinbutt_osx.cpp +++ b/src/osx/spinbutt_osx.cpp @@ -96,6 +96,10 @@ void wxSpinButton::TriggerScrollEvent(wxEventType scrollEvent) { inc = -1; } + else + { + wxFAIL_MSG( "Unexpected event" ); + } // trigger scroll events @@ -119,32 +123,23 @@ void wxSpinButton::TriggerScrollEvent(wxEventType scrollEvent) newValue = m_max; } - if ( newValue - oldValue == -1 ) - scrollEvent = wxEVT_SCROLL_LINEDOWN; - else if ( newValue - oldValue == 1 ) - scrollEvent = wxEVT_SCROLL_LINEUP; - else - scrollEvent = wxEVT_SCROLL_THUMBTRACK; - // Do not send an event if the value has not actually changed // (Also works for wxSpinCtrl) if ( newValue == oldValue ) return; - if ( scrollEvent != wxEVT_SCROLL_THUMBTRACK ) - { - wxSpinEvent event( scrollEvent, m_windowId ); + wxSpinEvent event( scrollEvent, m_windowId ); - event.SetPosition( newValue ); - event.SetEventObject( this ); - if ((HandleWindowEvent( event )) && !event.IsAllowed()) - newValue = oldValue; - } + event.SetPosition( newValue ); + event.SetEventObject( this ); + if ((HandleWindowEvent( event )) && !event.IsAllowed()) + newValue = oldValue; - GetPeer()->SetValue( newValue ); + SetValue( newValue ); - // always send a thumbtrack event - SendThumbTrackEvent() ; + // send a thumbtrack event if EVT_SPIN_UP/DOWN wasn't vetoed + if ( newValue != oldValue ) + SendThumbTrackEvent() ; } #endif // wxUSE_SPINBTN