문제

여기 내 문제가 있습니다.

패널에 메인 캔버스 '블랙 보드'가 있습니다.이 캔버스에는 도구 모음 (타일), 라벨 및 스키닝과 같은 여러 어린이가 있습니다.

문제는 사각형 도구로 이동하고 '서클'또는 '선택'과 같은 다른 도구를 클릭 할 때 도구를 변경하려면 사각형을 그리기 시작하면 버튼이 클릭 이벤트를 포착하지 않으며 강화하는 것입니다. 캔버스는 마우스를 잡고 그림을 그리기 시작합니다.

그림과 마찬가지로 그림을 시작하면 도구를 변경할 수 없습니다.

대체 텍스트 http://www.freeimagehosting.net/uploads/397a7cd49e.png

캔버스가 도구에있을 때 캔버스를 반응하게 만들 수 없거나 버튼을 먼저 클릭하고 캔버스에 아무것도 그릴 수 없다고 말할 수있는 방법.

물론 캔버스가 아닌 다른 곳에 도구 모음을 넣을 수는 있지만 공간이 중요하기 때문에 버튼이 캔버스에있는 것을 원합니다.

나는 어떤 제안에도 열려 있습니다.

=== 여기에 어떻게 작동하는지 보여주는 코드가 있습니다. ===

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" 
          xmlns:degrafa="http://www.degrafa.com/2007"
          xmlns:comp="org.foo.bar.view.components.*"
          layout="absolute"
          title="Tableau">


    <mx:Script>
    <![CDATA[
        import org.edorado.edoboard.ApplicationFacade;
    ]]>
    </mx:Script>

    <mx:Canvas id="blackBoard">

        <degrafa:Surface id="boardSurfaceContainer">
             skinning      
     </degrafa:Surface>

        <!-- Tool bar -->
        <comp:ToolbarView 
           id = "toolbar"
           name = "toolbar"
           verticalScrollPolicy="off" 
           horizontalScrollPolicy="off"
           bottom="5"
           right="5"
           top="5"
           direction="vertical"
           width="30" />   

        <mx:Label x="10" y="10" text="Label"  color="#FFFFFF" id="lbl"/>

    </mx:Canvas>

</mx:Panel>

도구 모음은 타일에 포함 된 버튼 목록입니다. Canvas 'Blackboard'는 여러 이벤트 처리, 특히 마우스를 아래로 내리고 모양을 그리기 위해 움직입니다.

...
boardCanvas.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);
            boardCanvas.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
...
        private function handleMouseDown(event:MouseEvent):void {
            // Get the current mouse location wich may be adjusted to the grid
            var selectPoint:Point = boardCanvas.globalToLocal(new Point(event.stageX, event.stageY));
            startPoint = snapPoint(selectPoint.x, selectPoint.y);
            boardView.lbl.text = '(' + startPoint.x +',' + startPoint.y + ')';
....

도구 모음은 클릭을 듣습니다

<?xml version="1.0" encoding="utf-8"?>
<mx:Tile xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        <![CDATA[
            import mx.charts.BubbleChart;
            import org.edorado.edoboard.view.components.shapes.*; 

            public static const TOOL_CHANGE:String  = "toolChange";
            public static const TEXT_TOOL:String  = "textTool";
            public static const SELECT_TOOL:String  = "selectTool";
            public static const RECTANGLE_TOOL:String  = "rectangleTool";

            private var b:Button = null;

            private function handleButtonClick(event:MouseEvent):void {
                trace("CLICKED  TOOL");
                // selectButton.dispatchEvent(new Event(TOOL_CHANGE, true, true)) 
                b = event.target as Button;
                b.dispatchEvent(new Event(TOOL_CHANGE, true, true));
            }


        ]]>
    </mx:Script>

          <!-- Use class facotry ? -->
          <mx:Button id="selectButton"
                     name="{SELECT_TOOL}"
                     selectedUpSkin="assets.skins.ToolButtonSkin"
                     width="30" 
                     height="30" 
                     styleName="selectButton" 
                     toolTip="selection" 
                     click="handleButtonClick(event); " />

          <mx:Button id="textButton"
                     name = "{TEXT_TOOL}"
                     selectedUpSkin="assets.skins.ToolButtonSkin"
                     width="30" 
                     height="30" 
                     styleName="textButton"  
                     toolTip="text"
                     click="handleButtonClick(event);" />

          <mx:Button id="rectButton" 
                     name = "{RECTANGLE_TOOL}"
                     selectedUpSkin="assets.skins.ToolButtonSkin"
                     width="30"
                     height="30"
                     styleName="rectButton"
                     toolTip="rectButton"
                     click="handleButtonClick(event);" />
</mx:Tile>
도움이 되었습니까?

해결책 2

고마워, 나는 도구 모음에서 마우스를 들었고 캔버스가 그것을 잡지 않도록 이벤트 전파를 중단했다.

다른 팁

당신은 그것을 사용할 수 있습니다 표적 당신의 재산 Mouseevent 클릭이 툴바에서 클릭 할 때 comportment를 차별화합니다. LIVEDOCS에서 전리품을 타고 목표 속성이 무엇인지 이해하십시오.

행운을 빕니다!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top