问题
i have my project developed in Flex3,
<<Site Link Removed now>>
You can check it here, the problem i am facing is, copying(Ctrl + C) the content from screen textarea when the swf is running in chrome browser.
suppose, i have to add some text on the stage, so the text area which is opened on the left side, i can't copy the text written in text area, although by right clicking in text area, and selcting the copy option, thats working, but my client has asked for copying the content by using Ctrl + c, although it's working very fine with other browsers,
only chrome is not supporting copying(Ctrl + c), although selecting all(Ctrl + A ) is working
so this the thing, which i thot i shd discuss, may b someone also hav same problem,
Thanking u all in advance,,
Ankur Sharma
回答1:
Use KeyboardEvent.KEY_DOWN
to detect "C" being pressed. Then check for ctrlKey
to see if it is down, and use System.setClipboard(source.text);
to set the clipboard content.
textArea.addEventListener (KeyboardEvent.KEY_DOWN, onKeyDown);
private function onKeyDown ( ev : KeyboardEvent ) : void
{
if (ev.keyCode != 67 || !ev.ctrlKey) return;
var text:String = textArea.text;
System.setClipboard( text);
}
Beware, though: Sometimes odd things can happen simultaneously, like the text content disappearing and such. You might have to work around that!
回答2:
It's not just chrome that does this, safari and some other browsers do it too.
Your best bet is to use a JavaScript library to catch these keyboard events and then pass them through to your Flex app.
For communicating between the two: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html
How to detect keyboard short cuts in JavaScript (have tested Ctrl+1 in Chrome on Windows XP: http://www.openjs.com/scripts/events/keyboard_shortcuts/
来源:https://stackoverflow.com/questions/4665497/ctrl-c-not-working-in-flash-playerswf-file-when-browser-is-google-chrome