Flex 4 and ScrollBar stepSize

一世执手 提交于 2019-12-14 04:05:29

问题


I want to specify amount to scroll with VScrollBar. So in Flex 3 we have "lineScrollSize" but how this property called in Flex 4? I thought it VScrolBar.stepSize — but it dose not do anything.

Somebody please help me. I just whant my content to scroll faster on mouse wheel.


回答1:


Have a look into LayoutBase.getVerticalScrollPositionDelta. You might want to subclass and override it!

Here's what I did in my own layout class:

override public function getVerticalScrollPositionDelta(navigationUnit:uint):Number {
    var n:Number=super.getVerticalScrollPositionDelta(navigationUnit);
    if (navigationUnit==NavigationUnit.DOWN || navigationUnit==NavigationUnit.UP) return 10*n;
    return n;
}



回答2:


There is an example of how to increase the stepSize for mouseWheel scrolling here: http://forums.adobe.com/message/2783736

You should be able to cancel mouseWheel scrolling a little easier with this enhancement: http://bugs.adobe.com/jira/browse/SDK-26432

The sub-task linked to that bug has a simple code sample that you should be able to modify to prevent mouse wheel scrolling and call your zooming logic instead:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark"> 
    <fx:Script> 
        <![CDATA[ 
            ...
            private function mouseWheelChangingHandler(event:FlexMouseEvent):void { 
                // don't scroll by preventing default
                event.preventDefault(); 

                // instead zoom
                yourZoomFunction(event.delta);
            } 
        ]]> 
    </fx:Script> 

    <s:Scroller id="scroller" width="250" height="200" mouseWheelChanging="mouseWheelChangingHandler(event)"> 
        <s:DataGroup id="vp" dataProvider="{getDP()}" itemRenderer="spark.skins.spark.DefaultItemRenderer"> 
            <s:layout> 
                <s:VerticalLayout gap="0" horizontalAlign="justify" /> 
            </s:layout> 
        </s:DataGroup> 
    </s:Scroller>
</s:Application>

The discussion in this thread might also be useful to you: http://forums.adobe.com/message/3393852#3393852




回答3:


I've come up with a workaround, which requires subclassing/extending the skins of the scrollbars.

This way you only have to use a custom scroller, rather then modify each viewport inside the scroller

I put it in the comment on the Flex SDK bug, which clearly should not have been ignored to begin with

https://bugs.adobe.com/jira/browse/SDK-17288



来源:https://stackoverflow.com/questions/1913721/flex-4-and-scrollbar-stepsize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!