Hi madhavi try it out and let me know....
private var nativeContextMenu:ContextMenu; // variable to store the
native context menu item
private var customContextMenu:ContextMenu; // variable to store the
custom context menu item
var customMenuItem:ContextMenuItem;
// This is done to retain native context menu
programList.contextMenu = nativeContextMenu;
//Logic for adding context menu item 'Remove this step'
customMenuItem = new ContextMenuItem("click me");
customContextMenu = new ContextMenu();
customContextMenu.hideBuiltInItems(); // hiding the default context
menu items
nativeContextMenu = customContextMenu.clone(); //Copy the native menu
item and store to nativeContextMenu
nativeContextMenu.builtInItems.print = true;
customContextMenu.customItems.push(customMenuItem);
//Handlers for menu click
customContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT,
onContextMenuClickHandler);
nativeContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT,
onContextMenuClickHandler);
customMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
onRemoveMenuClickHandler);
On Wed, Mar 2, 2011 at 9:56 AM, madhavi chinni
<[email protected]>wrote:
> Hi,
>
> I am add customItems in the ContextMenu.I have a function which
> creates Grid dynamically.I am setting the ContextMenu object to that
> GridItem.I am calling these two functions(ContextMenu
> creation,creation of the Grid) when application creation is complete.
>
> When I right click on the GridItem I am unable to see the CustomItems
> in the ContextMenu.
> But when I find the length of the CustomItems in the contextMenu of
> the GridItem it is giving me the correct length.
>
> Did anyone of you face this problem before?
>
> Please find the code snipplet below:
>
> private function init():void{
> var showSelection:ContextMenuItem = new
> ContextMenuItem("Show
> selection");
>
> showSelection.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
> showSelection_menuItemSelect);
>
> var upperCase:ContextMenuItem = new
> ContextMenuItem("Convert to
> upper case");
>
> upperCase.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
> upperCase_menuItemSelect);
>
> var lowerCase:ContextMenuItem = new
> ContextMenuItem("Convert to
> lower case");
>
> lowerCase.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
> lowerCase_menuItemSelect);
>
> cm = new ContextMenu();
> cm.hideBuiltInItems();
> cm.customItems.push(showSelection);
> cm.customItems.push(upperCase);
> cm.customItems.push(lowerCase);
>
>
>
> }
> code for assigning contextMenu to GridItem: grid_item.contextMenu=cm;
>
> code for when I am printing the length of the ContextMenu when I click
> on the GridItem:
> public function ClickHandler(event:MouseEvent):void
> {
>
> Alert.show(""+event.currentTarget.contextMenu.customItems.length);
>
>
>
> }
>
> Any help is greatly appreciated.
>
> Thanks,
> Madhavi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>
>
--
Regards,
Manikandan.S
http://www.umoldit.com
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.