Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

[#109] Add copyTest API #110

Closed
wants to merge 1 commit into from
Closed

Conversation

timnew
Copy link

@timnew timnew commented Feb 27, 2013

Allow zeroClipboard works as an clipboard service.
e.g:

window.zeroClipboard = new ZeroClipboard();

$('#copyTime').click(function(){
  zeroClipboard.copyTest(new Date().toLocaleTimeString());
});

@timnew timnew mentioned this pull request Feb 27, 2013
@jonrohan
Copy link
Contributor

This wont work because of flash restrictions. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/System.html#setClipboard()

This method works from any security context when called as a result of a user event (such as a keyboard or input device event handler).

What that means is they only will setClipboard data when you either click directly on a flash object, or press a key with the flash object as focused.

closing this as wont-fix because I can't change the security restrictions.

@jonrohan jonrohan closed this Feb 27, 2013
@timnew
Copy link
Author

timnew commented Feb 28, 2013

Thanks @jonrohan
I still have some question about this.
I knows little about AS, but is that possible to do something like this in AS:

function copyText(contentText) {
  setTimeout(0, function() {
    flash.system.System.setClipboard(contentText);
  });
}

Or how about trigger the mouse click event programatically? Does that work?

@jonrohan
Copy link
Contributor

I believe they still would need to originate from a mouse click. And you can't trigger one programmatically from what I could find.

@JamesMGreene
Copy link
Member

My understanding is the same as @jonrohan's: after all, it wouldn't be much of a user security mechanism if a malicious developer could get around it just by programmatically invoking a synthetic click event. Good for the user, annoying and untestable for the developer....

@timnew
Copy link
Author

timnew commented Mar 8, 2013

Understand, and agree to @JamesMGreene. It is good for user, but really annoying.
Just for curious, does HTML5 have any enhancement about Clipboard?

@jonrohan
Copy link
Contributor

jonrohan commented Mar 8, 2013

@timnew sort of. It's on our roadmap https://github.com/jonrohan/ZeroClipboard/blob/master/docs/roadmap.md, but there is limited support in browsers for it currently.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants