<?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; ContextMenuClipboardItems</title>
	<atom:link href="http://blog.flexexamples.com/category/contextmenuclipboarditems/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>Using a clipboard menu in Flex with Flash Player 10</title>
		<link>http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/</link>
		<comments>http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 08:21:57 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuClipboardItems]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[clipboardItems]]></category>
		<category><![CDATA[clipboardMenu]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/</guid>
		<description><![CDATA[<p>The following example shows how you can set a clipboard menu and specify custom clipboard items on a context menu by setting the contextMenu and clipboardItems properties.</p> <p>Full code after the jump.</p> <p></p> <p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set a clipboard menu and specify custom clipboard items on a context menu by setting the <code>contextMenu</code> and <code>clipboardItems</code> properties.</p>
<p>Full code after the jump.</p>
<p><span id="more-770"></span></p>
<p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see <a href="http://blog.flexexamples.com/2008/08/02/using-the-beta-gumbo-sdk-in-flex-builder-3/">Using the beta Gumbo SDK in Flex Builder 3&#8243;</a>.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ContextMenu_clipboardMenu_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/ --&gt;
&lt;Application name="ContextMenu_clipboardMenu_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        xmlns:ui="flash.ui.*"
        layout="flex.layout.BasicLayout"&gt;

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

            private function img_onEvent(evt:Event):void {
                Alert.show(evt.type);
            }

            private function img_menuSelect(evt:ContextMenuEvent):void {
                img.contextMenu.hideBuiltInItems();
            }
        ]]&gt;
    &lt;/Script&gt;

    &lt;mx:CheckBox id="checkBox"
            label="clipboardMenu"
            left="10"
            top="10" /&gt;

    &lt;mx:Image id="img"
            source="@Embed('assets/flashplayer_icon.jpg')"
            copy="img_onEvent(event);"
            cut="img_onEvent(event);"
            paste="img_onEvent(event);"
            horizontalCenter="0"
            verticalCenter="0"&gt;
        &lt;mx:contextMenu&gt;
            &lt;ui:ContextMenu clipboardMenu="{checkBox.selected}"
                    menuSelect="img_menuSelect(event);"&gt;
                &lt;ui:clipboardItems&gt;
                    &lt;ui:ContextMenuClipboardItems
                            copy="true"
                            cut="true"
                            paste="true"
                            selectAll="false" /&gt;
                &lt;/ui:clipboardItems&gt;
            &lt;/ui:ContextMenu&gt;
        &lt;/mx:contextMenu&gt;
    &lt;/mx:Image&gt;

&lt;/Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ContextMenu_clipboardMenu_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/ContextMenu_clipboardMenu_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>You can also specify custom clupboard items using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ContextMenu_clipboardMenu_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/ --&gt;
&lt;Application name="ContextMenu_clipboardMenu_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        layout="flex.layout.BasicLayout"
        initialize="init();"&gt;

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

            [Embed("assets/flashplayer_icon.jpg")]
            private var flashPlayerLogo:Class;

            private var cm:ContextMenu;

            private function init():void {
                cm = new ContextMenu();
                cm.hideBuiltInItems();
                cm.clipboardMenu = checkBox.selected;
                cm.clipboardItems.copy = true;
                cm.clipboardItems.cut = true;
                cm.clipboardItems.paste = true;
                cm.clipboardItems.selectAll = false;

                checkBox.label = "clipboardMenu";
                checkBox.addEventListener(Event.CHANGE, checkBox_change);
                checkBox.setStyle("left", 10);
                checkBox.setStyle("top", 10);

                img.contextMenu = cm;
                img.source = flashPlayerLogo;
                img.addEventListener(Event.COPY, img_onEvent);
                img.addEventListener(Event.CUT, img_onEvent);
                img.addEventListener(Event.PASTE, img_onEvent);
                img.setStyle("horizontalCenter", 0);
                img.setStyle("verticalCenter", 0);
            }

            private function checkBox_change(evt:Event):void {
                cm.clipboardMenu = checkBox.selected;
            }

            private function img_onEvent(evt:Event):void {
                Alert.show(evt.type);
            }
        ]]&gt;
    &lt;/Script&gt;

    &lt;mx:CheckBox id="checkBox" /&gt;
    &lt;mx:Image id="img" /&gt;

&lt;/Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using a clipboard menu in Flex with Flash Player 10 on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/',contentID: 'post-770',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'clipboardItems,clipboardMenu',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/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

