1 Reply Latest reply on Aug 12, 2010 6:07 AM by JabbyPandaUA

    Flex event copy, past with shortcut

    KAZatSAP Level 1

      Hello guys,

       

      I wrote a simple code to copy and past

      It work from context menu (right click) but very randomly with shortcut ctrl+v

      any clue ?

       

      code
      <?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="init()"
                     paste="onEvent(event)"
                     >
          <fx:Script>
              <![CDATA[
                  import flash.desktop.Clipboard;
                  import flash.desktop.ClipboardFormats;
                  import mx.controls.Alert;
                  private var cm:ContextMenu;
                 
                  private function init():void {
                      cm = new ContextMenu();
                      cm.hideBuiltInItems();
                      cm.clipboardMenu = true;
                      cm.clipboardItems.paste = true;
                      cm.clipboardItems.selectAll = false;
                      contextMenu = cm;   
                  }
                 
                  private function onEvent(evt:Event):void {
                      Alert.show(evt.type+"\n"+String(Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_ FORMAT)));
                  }
              ]]>
          </fx:Script>   
      </s:Application>