I need to copy an URL (in fact an URL of an image) to the clipboard inside my app then paste it in another app (iMessenger, but the other app is not important, right now).
I can’t use the usual setData, like this
Clipboard.generalClipboard.setData(ClipboardFormats.URL_FORMAT, “ http://myimage.com/image.jpg”);
because only theses threes format at supported by ClipboardFormats:
public var HTML_FORMAT = "air:html";
public var RICH_TEXT_FORMAT = "air:rtf";
public var TEXT_FORMAT = "air:text";
I know that more format are available “natively”, but I’m not quite sure if we can access them? Anybody had any luck with this?
This is supported (without legacy) for copying text. Does that work? Just use text type?
Yes. with the text mode the clipboard works fine, but iOS don’t handle “text” clipboard and “url” clipboard the same way. So in text mode, it will paste the URL as regular text, but in “url” mode it will try to paste the content of the URL, in my case an image.
I have seen an implementation of the titanium api in haxe that seem to be handling more advanced copy mode, but i haven’t been able to import it correctly in my project.
Basically, what i want to do would be something like:
Clipboard.generalClipboard.setData(“text/uri-list”, “ http://myimage.com/image.jpg”);
Not quite sure if this is not implemented or not permitted outside native app. In native the format is “text/uri-list”.
Looks like this is the code for now:
This file has been truncated.
Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
I think this is used on iOS. It may be possible to use this code as a starting point reference for creating clipboard support with other meta types