private void SkinMouseWheelHandler(Event e) { MouseEvent me = (MouseEvent)e; IViewport vp = Viewport; if (e.DefaultPrevented || null == vp || !vp.Visible) { return; } var delta = me.CurrentEvent.delta.y; int nSteps = (int)Math.Abs(delta); NavigationUnit navigationUnit; // Scroll event.delta "steps". If the VSB is up, scroll vertically, // if -only- the HSB is up then scroll horizontally. if (null != VerticalScrollBar && VerticalScrollBar.Visible) { navigationUnit = (delta < 0) ? NavigationUnit.Down : NavigationUnit.Up; for (int vStep = 0; vStep < nSteps; vStep++) { float?vspDelta = vp.GetVerticalScrollPositionDelta(navigationUnit); //if (null != vspDelta) vp.VerticalScrollPosition += (float)vspDelta; } e.PreventDefault(); } else if (null != HorizontalScrollBar && HorizontalScrollBar.Visible) { navigationUnit = (delta < 0) ? NavigationUnit.Right : NavigationUnit.Left; for (int hStep = 0; hStep < nSteps; hStep++) { float hspDelta = vp.GetHorizontalScrollPositionDelta(navigationUnit); //if (null != hspDelta) vp.HorizontalScrollPosition += hspDelta; } e.PreventDefault(); } }
private void MouseWheelHandler(Event e) { //Debug.Log("VScrollBar->MouseWheelHandler: " + e.Target); IViewport vp = Viewport; if (e.DefaultPrevented || null == vp || !vp.Visible) { return; } /* If the scrollbar is a part of the scroller, but is not visible, do not process mouse wheel * this way we are giving a chance for the horizontal scroll to work */ if (!Visible) { return; } MouseEvent me = (MouseEvent)e; //Debug.Log(me.CurrentEvent.delta.y); var delta = me.CurrentEvent.delta.y; int nSteps = (int)Math.Abs(delta); //Debug.Log("MouseWheelHandler. delta: " + delta); // Scroll event.delta "steps". nSteps = 1; // TEMP NavigationUnit navigationUnit = (delta > 0) ? NavigationUnit.Down : NavigationUnit.Up; for (int vStep = 0; vStep < nSteps; vStep++) { //Debug.Log("vStep: " + vStep); float vspDelta = vp.GetVerticalScrollPositionDelta(navigationUnit); //Debug.Log(" vspDelta: " + vspDelta); //if (null != vspDelta) vp.VerticalScrollPosition += vspDelta; } e.PreventDefault(); }