diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index 0367238bd6..791ac524dd 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -389,12 +389,10 @@ void EDA_DRAW_PANEL::OnActivate( wxActivateEvent& event ) void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) { int id = event.GetEventType(); - int dir; int x, y; int ppux, ppuy; int csizeX, csizeY; int unitsX, unitsY; - int maxX, maxY; GetViewStart( &x, &y ); GetScrollPixelsPerUnit( &ppux, &ppuy ); @@ -410,10 +408,18 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) unitsX /= ppux; unitsY /= ppuy; - maxX = unitsX - csizeX; - maxY = unitsY - csizeY; + int dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL - dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL + // On windows and on wxWidgets >= 2.9.5 and < 3.1, + // there is a bug in mousewheel event which always generates 2 scroll events + // (should be the case only for the default mousewheel event) + // with id = wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN + // so we skip these events. + // Note they are here just in case, because they are not actually used + // in Kicad +#if wxCHECK_VERSION( 3, 1, 0 ) || !wxCHECK_VERSION( 2, 9, 5 ) || !defined (__WINDOWS__) + int maxX = unitsX - csizeX; + int maxY = unitsY - csizeY; if( id == wxEVT_SCROLLWIN_LINEUP ) { @@ -448,7 +454,9 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) y = maxY; } } - else if( id == wxEVT_SCROLLWIN_THUMBTRACK ) + else +#endif + if( id == wxEVT_SCROLLWIN_THUMBTRACK ) { if( dir == wxHORIZONTAL ) x = event.GetPosition();