2 Replies Latest reply on Apr 14, 2010 6:05 PM by slim0001

    How do I add a contextMenu to a spark Panel...

    ablerman

      I've tried doing it the way that I used in Flex 3.5, but it doesn't seem to work in Spark. Is this a bug in spark?

       

      I've included code to demonstrate the problem, it has a Spark Panel and a Halo Panel, the Spark Panel doesn't have the correct ContextMenu, but the Halo Panel does.

       

      Any ideas what I'm doing wrong?

       

      ------------------------------------------------------------ SNIP ------------------------------------------------------------

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

         xmlns:s="library://ns.adobe.com/flex/spark"

         xmlns:mx="library://ns.adobe.com/flex/mx"

         minWidth="955" minHeight="600"  creationComplete="createComplete()" >

      <fx:Declarations>

      <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

      <fx:Script>

      <![CDATA[

       

      private function createComplete() : void  {

      var contextMenu:ContextMenu = new ContextMenu();

      contextMenu.hideBuiltInItems();

       

      var customItems:Array = new Array;

      var item:ContextMenuItem;

       

      item = new ContextMenuItem("Item1", false, true, true);

      customItems.push(item);

       

      item = new ContextMenuItem("Item2", false, true, true);

      customItems.push(item);

       

       

      contextMenu.customItems = customItems;

      haloPanel.contextMenu = contextMenu;

      sparkPanel.contextMenu = contextMenu;

      }

      ]]>

      </fx:Script>

       

      <s:Panel id="sparkPanel" width="50%" height="100%" backgroundColor="0x00ff00"/>

       

      <mx:Panel id="haloPanel" x="{width/2}" width="50%" height="100%" backgroundColor="0x0000ff"/>

      </s:Application>

      ------------------------------------------------------------ SNIP ------------------------------------------------------------