<?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; menuItemSelect</title>
	<atom:link href="http://blog.flexexamples.com/tag/menuitemselect/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>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>

