<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; ContextMenuItem</title>
	<atom:link href="http://blog.flexexamples.com/category/contextmenuitem/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting a custom context menu on a Spark List control item renderer in Flex 4</title>
		<link>http://blog.flexexamples.com/2010/05/06/setting-a-custom-context-menu-on-a-spark-list-control-item-renderer-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2010/05/06/setting-a-custom-context-menu-on-a-spark-list-control-item-renderer-in-flex-4/#comments</comments>
		<pubDate>Fri, 07 May 2010 00:27:11 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuEvent]]></category>
		<category><![CDATA[ContextMenuItem]]></category>
		<category><![CDATA[Flex4]]></category>
		<category><![CDATA[List (Spark)]]></category>
		<category><![CDATA[dataChange]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[itemRenderer]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2945</guid>
		<description><![CDATA[<p>The following example shows how you can set a custom context menu on a Spark List control item renderer in Flex 4 by setting the contextMenu property in the item renderer&#8217;s dataChange event.</p> <p></p> &#60;?xml version=&#34;1.0&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/05/06/setting-a-custom-context-menu-on-a-spark-list-control-item-renderer-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_List_itemRenderer_contextMenu_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/mx&#34;&#62; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; import mx.utils.StringUtil; &#160; protected function lst_labelFunc&#40;data:Object&#41;:String &#123; return [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set a custom context menu on a Spark List control item renderer in Flex 4 by setting the <code>contextMenu</code> property in the item renderer&#8217;s <code>dataChange</code> event.</p>
<p><span id="more-2945"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/05/06/setting-a-custom-context-menu-on-a-spark-list-control-item-renderer-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_List_itemRenderer_contextMenu_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span> 
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.utils.StringUtil;</span>
&nbsp;
<span style="color: #000000;">            protected function lst_labelFunc<span style="color: #66cc66;">&#40;</span>data:Object<span style="color: #66cc66;">&#41;</span>:String <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                return StringUtil.substitute<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;[{0}]\t{1}&quot;</span>, data.symbol, data.name<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;lst&quot;</span></span>
<span style="color: #000000;">            labelFunction=<span style="color: #ff0000;">&quot;lst_labelFunc&quot;</span></span>
<span style="color: #000000;">            itemRenderer=<span style="color: #ff0000;">&quot;skins.CustomColumnItemRen&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;250&quot;</span></span>
<span style="color: #000000;">            horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> gap=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                    horizontalAlign=<span style="color: #ff0000;">&quot;justify&quot;</span></span>
<span style="color: #000000;">                    requestedRowCount=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> symbol=<span style="color: #ff0000;">&quot;ADBE&quot;</span> name=<span style="color: #ff0000;">&quot;Adobe Systems Incorporated&quot;</span> price=<span style="color: #ff0000;">&quot;32.49&quot;</span> isNew=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> symbol=<span style="color: #ff0000;">&quot;AAPL&quot;</span> name=<span style="color: #ff0000;">&quot;Apple Inc.&quot;</span> price=<span style="color: #ff0000;">&quot;246.25&quot;</span> isNew=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> symbol=<span style="color: #ff0000;">&quot;GOOG&quot;</span> name=<span style="color: #ff0000;">&quot;Google Inc.&quot;</span> price=<span style="color: #ff0000;">&quot;498.67&quot;</span> isNew=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> symbol=<span style="color: #ff0000;">&quot;HPQ&quot;</span> name=<span style="color: #ff0000;">&quot;Hewlett-Packard Company&quot;</span> price=<span style="color: #ff0000;">&quot;48.33&quot;</span> isNew=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> symbol=<span style="color: #ff0000;">&quot;IBM&quot;</span> name=<span style="color: #ff0000;">&quot;International Business Machines Corp.&quot;</span> price=<span style="color: #ff0000;">&quot;123.92&quot;</span> isNew=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> symbol=<span style="color: #ff0000;">&quot;NVDA&quot;</span> name=<span style="color: #ff0000;">&quot;NVIDIA Corporation&quot;</span> price=<span style="color: #ff0000;">&quot;14.20&quot;</span> isNew=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ArrayList</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>And the custom Spark List control item renderer, <em>skins/CustomColumnItemRen.mxml</em>, is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/05/06/setting-a-custom-context-menu-on-a-spark-list-control-item-renderer-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ItemRenderer</span> name=<span style="color: #ff0000;">&quot;CustomColumnItemRen&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">        autoDrawBackground=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">        dataChange=<span style="color: #ff0000;">&quot;dataChangeHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;normal&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;hovered&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;selected&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span> gap=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                paddingLeft=<span style="color: #ff0000;">&quot;3&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;3&quot;</span></span>
<span style="color: #000000;">                paddingTop=<span style="color: #ff0000;">&quot;3&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;3&quot;</span></span>
<span style="color: #000000;">                verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.controls.Alert;</span>
<span style="color: #000000;">            import mx.formatters.CurrencyFormatter;</span>
&nbsp;
<span style="color: #000000;">            <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;assets/bullet_star.png&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></span>
<span style="color: #000000;">            protected const ICON:Class;</span>
&nbsp;
<span style="color: #000000;">            protected function dataChangeHandler<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                const currFmt:CurrencyFormatter = new CurrencyFormatter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                currFmt.precision = <span style="color: #cc66cc;">2</span>;</span>
&nbsp;
<span style="color: #000000;">                priceTxt.text = currFmt.format<span style="color: #66cc66;">&#40;</span>data.price<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span>data.isNew<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    bmpImg.source = ICON;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">                // Create custom context menu. </span>
<span style="color: #000000;">                const cmi:ContextMenuItem = new ContextMenuItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Copy quote&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                cmi.addEventListener<span style="color: #66cc66;">&#40;</span>ContextMenuEvent.MENU_ITEM_SELECT, cmi_menuItemSelect<span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #000000;">                const cm:ContextMenu = new ContextMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                cm.hideBuiltInItems<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                cm.customItems = <span style="color: #66cc66;">&#91;</span>cmi<span style="color: #66cc66;">&#93;</span>;</span>
&nbsp;
<span style="color: #000000;">                contextMenu = cm;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function cmi_menuItemSelect<span style="color: #66cc66;">&#40;</span>evt:ContextMenuEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                System.setClipboard<span style="color: #66cc66;">&#40;</span>labelDisplay.text + <span style="color: #ff0000;">&quot;\t&quot;</span> + priceTxt.text<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> id=<span style="color: #ff0000;">&quot;labelDisplay&quot;</span> maxDisplayedLines=<span style="color: #ff0000;">&quot;1&quot;</span> showTruncationTip=<span style="color: #ff0000;">&quot;true&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> id=<span style="color: #ff0000;">&quot;priceTxt&quot;</span> textAlign=<span style="color: #ff0000;">&quot;right&quot;</span> fontWeight=<span style="color: #ff0000;">&quot;bold&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapImage</span> id=<span style="color: #ff0000;">&quot;bmpImg&quot;</span> width=<span style="color: #ff0000;">&quot;16&quot;</span> height=<span style="color: #ff0000;">&quot;16&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ItemRenderer</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_List_itemRenderer_contextMenu_test/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_List_itemRenderer_contextMenu_test/main.html" width="100%" height="300"></iframe></p>
<p class="alert">Icons copyright of <a href="http://www.famfamfam.com/lab/icons/">famfamfam.com</a>.</p>
<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting a custom context menu on a Spark List control item renderer in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/05/06/setting-a-custom-context-menu-on-a-spark-list-control-item-renderer-in-flex-4/',contentID: 'post-2945',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'ContextMenu,dataChange,Gumbo,itemRenderer',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2010/05/06/setting-a-custom-context-menu-on-a-spark-list-control-item-renderer-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding custom context menu items to a Flex 4 application</title>
		<link>http://blog.flexexamples.com/2009/10/18/adding-custom-context-menu-items-to-a-flex-4-application/</link>
		<comments>http://blog.flexexamples.com/2009/10/18/adding-custom-context-menu-items-to-a-flex-4-application/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 15:31:28 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuItem]]></category>
		<category><![CDATA[customItems]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[topLevelApplication]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2032</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/">&#8220;Adding custom context menu items to a Flex application&#8221;</a>, we saw you could add custom context menu items to a Flex application by creating new ContextMenuItem objects and adding them to the Flex application&#8217;s customItems array (via the contextMenu property).</p> <p>The following example shows how you can add custom context [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/">&#8220;Adding custom context menu items to a Flex application&#8221;</a>, we saw you could add custom context menu items to a Flex application by creating new ContextMenuItem objects and adding them to the Flex application&#8217;s <code>customItems</code> array (via the <code>contextMenu</code> property).</p>
<p>The following example shows how you can add custom context menu items to a Flex 4 application by creating new ContextMenuItem objects and adding them to the Flex application&#8217;s <code>customItems</code> array (via the <code>contextMenu</code> property, and using the <code>FlexGlobals.topLevelApplication</code> property instead of the <code>application</code> property).</p>
<p>Full code after the jump.</p>
<p><span id="more-2032"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/10/18/adding-custom-context-menu-items-to-a-flex-4-application/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_Application_contextMenu_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span></span>
<span style="color: #000000;">        initialize=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.core.FlexGlobals;</span>
&nbsp;
<span style="color: #000000;">            private function init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var customMenuItem1:ContextMenuItem = new ContextMenuItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Flex SDK &quot;</span> + mx_internal::VERSION, false, false<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                var customMenuItem2:ContextMenuItem = new ContextMenuItem<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Player &quot;</span> + Capabilities.version, false, false<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                var contextMenuCustomItems:Array = FlexGlobals.topLevelApplication.contextMenu.customItems;</span>
<span style="color: #000000;">                contextMenuCustomItems.push<span style="color: #66cc66;">&#40;</span>customMenuItem1<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                contextMenuCustomItems.push<span style="color: #66cc66;">&#40;</span>customMenuItem2<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;Right click to see custom context menu items.&quot;</span></span>
<span style="color: #000000;">             horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding custom context menu items to a Flex 4 application on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/10/18/adding-custom-context-menu-items-to-a-flex-4-application/',contentID: 'post-2032',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'ContextMenu,customItems,Gumbo,topLevelApplication',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2009/10/18/adding-custom-context-menu-items-to-a-flex-4-application/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Adding custom context menu items to a Flex application</title>
		<link>http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/</link>
		<comments>http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 18:14:07 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuItem]]></category>
		<category><![CDATA[customItems]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/</guid>
		<description><![CDATA[<p>The following example shows how you can add custom context menu items to a Flex application by creating new ContextMenuItem objects and adding them to the Flex application&#8217;s customItems array (via the contextMenu property).</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_contextMenu_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/ --&#62; &#60;mx:Application name=&#34;Application_contextMenu_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can add custom context menu items to a Flex application by creating new ContextMenuItem objects and adding them to the Flex application&#8217;s <code>customItems</code> array (via the <code>contextMenu</code> property).</p>
<p>Full code after the jump.</p>
<p><span id="more-848"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_contextMenu_test/bin/srcview/source/main.mxml.html">View MXML</a></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;Application_contextMenu_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span></span>
<span style="color: #000000;">        initialize=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            private function init():void {</span>
<span style="color: #339933;">                var customMenuItem1:ContextMenuItem = new ContextMenuItem(&quot;Flex SDK &quot; + mx_internal::VERSION, false, false);</span>
<span style="color: #339933;">                var customMenuItem2:ContextMenuItem = new ContextMenuItem(&quot;Player &quot; + Capabilities.version, false, false);</span>
<span style="color: #339933;">                var contextMenuCustomItems:Array = application.contextMenu.customItems;</span>
<span style="color: #339933;">                contextMenuCustomItems.push(customMenuItem1);</span>
<span style="color: #339933;">                contextMenuCustomItems.push(customMenuItem2);</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;Right click to see custom context menu items.&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_contextMenu_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Application_contextMenu_test/bin/main.html" width="100%" height="100"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding custom context menu items to a Flex application on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/',contentID: 'post-848',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'customItems',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Creating a custom context menu on a RichTextEditor control in Flex</title>
		<link>http://blog.flexexamples.com/2007/12/31/creating-a-custom-context-menu-on-a-richtexteditor-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2007/12/31/creating-a-custom-context-menu-on-a-richtexteditor-control-in-flex/#comments</comments>
		<pubDate>Tue, 01 Jan 2008 06:03:35 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuEvent]]></category>
		<category><![CDATA[ContextMenuItem]]></category>
		<category><![CDATA[RichTextEditor]]></category>
		<category><![CDATA[hideBuiltInItems()]]></category>
		<category><![CDATA[menuItemSelect]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/31/creating-a-custom-context-menu-on-a-richtexteditor-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can add custom context menu commands to a RichTextEditor control in Flex by setting the contextMenu property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RichTextEditor_contextMenu_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/12/31/creating-a-custom-context-menu-on-a-richtexteditor-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init();"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; [Bindable] private var cm:ContextMenu; private function [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can add custom context menu commands to a RichTextEditor control in Flex by setting the <code>contextMenu</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-404"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RichTextEditor_contextMenu_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/12/31/creating-a-custom-context-menu-on-a-richtexteditor-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;

            [Bindable]
            private var cm:ContextMenu;

            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);

                richTextEditor.contextMenu = cm;
            }

            private function showSelection_menuItemSelect(evt:ContextMenuEvent):void {
                var selText:String = richTextEditor.selection.text;
                if (selText.length == 0) {
                    Alert.show("Please select some text.", "** ERROR **");
                } else {
                    Alert.show(selText, selText.length + " character(s)");
                }
            }

            private function upperCase_menuItemSelect(evt:ContextMenuEvent):void {
                var selText:String = richTextEditor.selection.text;
                richTextEditor.selection.text = selText.toUpperCase();
            }

            private function lowerCase_menuItemSelect(evt:ContextMenuEvent):void {
                var selText:String = richTextEditor.selection.text;
                richTextEditor.selection.text = selText.toLowerCase();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:RichTextEditor id="richTextEditor"
            title="Rich Text Editor"
            status="status message"
            width="100%"
            height="100%"&gt;
        &lt;mx:text&gt;&lt;![CDATA[Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec lacus est, ullamcorper sit amet, gravida at, viverra sit amet, lacus. Aliquam quis lectus id nisl condimentum hendrerit. Maecenas metus libero, dictum et, scelerisque vel, hendrerit non, felis. Duis venenatis, ligula eu lobortis lobortis, turpis erat eleifend eros, vitae auctor tortor mi in urna. Etiam aliquam, tellus aliquet placerat malesuada, orci sem rhoncus lectus, a elementum neque odio vitae urna. Pellentesque eget felis. Aenean at nisi. Proin felis. Curabitur scelerisque risus eget purus. Sed commodo eros in dolor. Sed quis lectus. Integer iaculis leo quis enim. Maecenas orci. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean et massa sit amet nibh fermentum accumsan. Maecenas aliquam metus dapibus mi. Pellentesque egestas posuere leo. Maecenas pellentesque diam non augue. Nulla vel nisi sit amet eros suscipit sagittis.]]&gt;&lt;/mx:text&gt;
    &lt;/mx:RichTextEditor&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RichTextEditor_contextMenu_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/RichTextEditor_contextMenu_test/bin/main.html" width="100%" height="400"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating a custom context menu on a RichTextEditor control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/12/31/creating-a-custom-context-menu-on-a-richtexteditor-control-in-flex/',contentID: 'post-404',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'hideBuiltInItems(),menuItemSelect',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/12/31/creating-a-custom-context-menu-on-a-richtexteditor-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a custom context menu with the Flex DataGrid control</title>
		<link>http://blog.flexexamples.com/2007/08/20/using-a-custom-context-menu-with-the-flex-datagrid-control/</link>
		<comments>http://blog.flexexamples.com/2007/08/20/using-a-custom-context-menu-with-the-flex-datagrid-control/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 05:19:53 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuItem]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[menuItemSelect]]></category>
		<category><![CDATA[menuSelect]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/20/using-a-custom-context-menu-with-the-flex-datagrid-control/</guid>
		<description><![CDATA[<p>I saw this question come up on a list today and thought this was pretty handy. Plus, I think it is the first time I&#8217;ve had a chance to play with the ContextMenu and ContextMenuItem classes in Flex in quite a while.</p> <p>The following example pops up a custom context menu when the user right-clicks [...]]]></description>
			<content:encoded><![CDATA[<p>I saw this question come up on a list today and thought this was pretty handy. Plus, I think it is the first time I&#8217;ve had a chance to play with the ContextMenu and ContextMenuItem classes in Flex in quite a while.</p>
<p>The following example pops up a custom context menu when the user right-clicks on an item in an data grid. After selecting the custom item (&#8220;View item&#8230;&#8221;) from the context menu an Alert control is displayed showing the selected item&#8217;s properties.</p>
<p>Full code after the jump.</p>
<p><span id="more-105"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_contextMenu_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/08/20/using-a-custom-context-menu-with-the-flex-datagrid-control/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;

            [Bindable]
            private var cm:ContextMenu;

            private var alert:Alert;

            private function init():void {
                var cmi:ContextMenuItem = new ContextMenuItem("View item...", true);
                cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuItem_menuItemSelect);

                cm = new ContextMenu();
                cm.hideBuiltInItems();
                cm.customItems = [cmi];
                cm.addEventListener(ContextMenuEvent.MENU_SELECT, contextMenu_menuSelect);
            }

            private function contextMenu_menuSelect(evt:ContextMenuEvent):void {
                dataGrid.selectedIndex = lastRollOverIndex;
            }

            private function contextMenuItem_menuItemSelect(evt:ContextMenuEvent):void {
                var obj:Object = dataGrid.selectedItem;
                alert = Alert.show("Property A: " + obj.@propertyA + "\\n" + "Property B: " + obj.@propertyB, obj.@label, Alert.OK);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="itemsXML"&gt;
        &lt;items&gt;
            &lt;item label="Item 1" data="i001" propertyA="Item 1.A" propertyB="Item 1.B" /&gt;
            &lt;item label="Item 2" data="i002" propertyA="Item 2.A" propertyB="Item 2.B" /&gt;
            &lt;item label="Item 3" data="i003" propertyA="Item 3.A" propertyB="Item 3.B" /&gt;
            &lt;item label="Item 4" data="i004" propertyA="Item 4.A" propertyB="Item 4.B" /&gt;
            &lt;item label="Item 5" data="i005" propertyA="Item 5.A" propertyB="Item 5.B" /&gt;
            &lt;item label="Item 6" data="i006" propertyA="Item 6.A" propertyB="Item 6.B" /&gt;
            &lt;item label="Item 7" data="i007" propertyA="Item 7.A" propertyB="Item 7.B" /&gt;
            &lt;item label="Item 8" data="i008" propertyA="Item 8.A" propertyB="Item 8.B" /&gt;
        &lt;/items&gt;
    &lt;/mx:XML&gt;

    &lt;mx:Number id="lastRollOverIndex" /&gt;

    &lt;mx:DataGrid id="dataGrid"
            width="400"
            dataProvider="{itemsXML.item}"
             contextMenu="{cm}"
             itemRollOver="lastRollOverIndex = event.rowIndex"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn id="labelCol"
                    dataField="@label"
                    headerText="Label:" /&gt;

            &lt;mx:DataGridColumn id="propACol"
                    dataField="@propertyA"
                    headerText="Property A:" /&gt;

            &lt;mx:DataGridColumn id="propBCol"
                    dataField="@propertyB"
                    headerText="Property B:" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

    &lt;mx:Label text="{dataGrid.selectedItem.@label}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_contextMenu_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/DataGrid_contextMenu_test/bin/main.html" width="100%" height="250"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using a custom context menu with the Flex DataGrid control on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/20/using-a-custom-context-menu-with-the-flex-datagrid-control/',contentID: 'post-105',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'menuItemSelect,menuSelect',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/08/20/using-a-custom-context-menu-with-the-flex-datagrid-control/feed/</wfw:commentRss>
		<slash:comments>57</slash:comments>
		</item>
	</channel>
</rss>

