如何使组件可以从组件内的Scroller以外的任何部分拖动

时间:2013-09-26 20:45:20

标签: flex

Problem Description

我和内部的Flex组件有一个profundidad组件Scroller上有DataGroup

组件可以很好地拖动,但是当我尝试拖动滚动条时拖动整个组件而不是拖动滚动条本身

如何使组件可以从滚动条以外的任何其他部分拖动,并使滚动条上的拖动按预期运行(在上方或下方显示更多信息) 吗

主要组件的代码是

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx"
         xmlns:c="Components.ComponentsMulticuenta.*"
         xmlns:c1="Components.*"
         xmlns:Front="Components.Front.*"
         mouseDown="initialPosition(event)" mouseUp="finalPosition(event)" 
         width="250" height.Start="94">

         private var isDragging:Boolean ;

            protected function initialPosition(event:MouseEvent):void
            {
                isDragging = false ;

                if(event.localY <= 94)
                {
                    this.startDrag();

                    isDragging = true ;
                }
            }
            protected function finalPosition(event:MouseEvent):void
            {
                if(isDragging)
                {
                    this.stopDrag();
                    isDragging = false ;
                }
            }

    <s:states>
        <s:State name="Start"/>
        <s:State name="stateDown"/>
    </s:states>

    <s:BorderContainer borderStyle="solid"
                       top="0" width="100%" height="94" height.stateDown="210"
                       borderColor="#4F5548" horizontalCenter="0">
        <mx:Canvas id="fondo"  width="100%" height="100%">
            <c:profundidad includeIn="stateDown" id="prof" left="0" right="0" top="90" arrProff="{MarketInfoArray}"/>
        </mx:Canvas>
    </s:BorderContainer>
</s:Group>

profundidad组件的代码是

<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
           xmlns:s="library://ns.adobe.com/flex/spark"
           xmlns:mx="library://ns.adobe.com/flex/mx"
           width="248" height="100%">
           <s:BorderContainer width="100%" height="100%" >

        <s:Scroller id="scroll" left="0" right="0" top="32" bottom="0" focusEnabled="false" hasFocusableChildren="true" >
            <s:DataGroup left="0" right="0" top="0" bottom="0" dataProvider="{arrProff}"
                             itemRenderer="Components.ComponentsMulticuenta.DepthRender">
            <s:layout>
                <s:VerticalLayout gap="1"/>
            </s:layout>
            </s:DataGroup>      
        </s:Scroller>
    </s:BorderContainer>
</mx:Canvas>

1 个答案:

答案 0 :(得分:0)

避免来自“关闭”按钮和滚动条的拖动,滚动条在flex中具有标识thumb(对于SliderThumb)

这就是我做的事情

protected function initialPosition(event:MouseEvent):void
{
    isDragging = false ;

    if( event.target.hasOwnProperty("id") && (event.target.id != "close") && (event.target.id != "thumb"))
    {
        this.startDrag();

        isDragging = true ;

        parentApplication.showNemo(this) ;
    }
}