0

问题描述

我有一个 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>
4

1 回答 1

0

为了避免从“关闭”按钮和滚动条中拖动,在 flex 中具有 id 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) ;
    }
}
于 2013-10-01T13:58:12.260 回答