2 Replies Latest reply on Oct 29, 2006 11:53 PM by sobaka11

    Problem with DragEnter event

    sobaka11
      I 've created menu and dragEnter event listener on it. I want the cursor to be green, when it's over menu( during dragging). But the cursor becomes green not over the menu, but at right and down from the menu. Why?

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Script>
      <![CDATA[
      // Import the Menu control.
      import mx.controls.Menu;
      import mx.events.MenuEvent;
      import mx.events.DragEvent;
      import mx.managers.DragManager;
      import mx.core.UIComponent;
      import mx.containers.Canvas;
      import mx.controls.DataGrid;
      import mx.core.DragSource;

      private var myMenu:Menu;

      // Create and display the Menu control.
      private function createAndShow():void {
      // The third parameter sets the showRoot property to false.
      // You must set this property in the createMenu method, not later.
      myMenu = Menu.createMenu(null, myMenuData, false);
      myMenu.labelField="@label";
      myMenu.show(300, 200);
      myMenu.addEventListener(DragEvent.DRAG_ENTER, handleDragEnter,true);
      // DragManager.
      }

      private function handleDragEnter(event:DragEvent):void
      {
      event.preventDefault();
      var dropTarget : UIComponent = UIComponent(event.currentTarget);
      DragManager.acceptDragDrop(dropTarget);
      DragManager.showFeedback(DragManager.COPY);
      }

      ]]>
      </mx:Script>

      <!-- Define the menu data. -->
      <mx:XML format="e4x" id="myMenuData">
      <root>
      <menuitem label="MenuItem A" >
      <menuitem label="SubMenuItem A-1" enabled="False"/>
      <menuitem label="SubMenuItem A-2"/>
      </menuitem>
      <menuitem label="MenuItem B" type="check" toggled="true"/>
      <menuitem label="MenuItem C" type="check" toggled="false"/>
      <menuitem type="separator"/>
      <menuitem label="MenuItem D" >
      <menuitem label="SubMenuItem D-1" type="radio" groupName="one"/>
      <menuitem label="SubMenuItem D-2" type="radio" groupName="one"
      toggled="true"/>
      <menuitem label="SubMenuItem D-3" type="radio" groupName="one"/>
      </menuitem>
      </root>
      </mx:XML>

      <mx:VBox>
      <!-- Define a Button control to open the menu -->
      <mx:Button id="myButton" label="Open Menu" dragEnter="createAndShow()" click="createAndShow()"/>
      </mx:VBox>

      <mx:DataGrid dragEnabled="true">
      <mx:ArrayCollection>
      <mx:Object Artist="Pavement" Price="11.99"
      Album="Slanted and Enchanted" />
      <mx:Object Artist="Pavement"
      Album="Brighten the Corners" Price="11.99" />
      </mx:ArrayCollection>
      <mx:columns>
      <mx:DataGridColumn dataField="Album" />
      <mx:DataGridColumn dataField="Price" />
      </mx:columns>
      </mx:DataGrid>
      </mx:Application>

      Steps:
      -Drag an item from dataGrid
      -Drag over the button -> menu appears
      -Drag over menu -> cursor doesn't change
      -Drag at right and down from the menu -> cursor is green

      Advise me please how to fix this problem