01-04-2013 09:14 AM - edited 01-05-2013 05:09 AM
I would like to copy a text from QML into the clipboard.
It seems QML does not provide a way for this?
I only found solutions for C++ (http://supportforums.blackberry.com/t5/Cascades-De
But since I am not using C++, this is not an option ![]()
01-04-2013 10:54 AM - edited 01-04-2013 10:55 AM
Unfortunately there are going to be things that will require some C++ however not all is lost, there's 2 ways of doing that, the NDK way or the cascades way which is the link you posted & will work even if you're sticking mainly to QML...
in you're .cpp
void AppName::copyText(QByteArray text)
{
Clipboard clipboard;
clipboard.clear();
clipboard.insert("text/plain", text);
}in you're .hpp
public:
Q_INVOKABLE
void copyText(QByteArray text);
to access via QML stick this in a buttons onClicked() or something similar
AppName.copyText(myTextArea.text);
AppName is your "context property" which should be set in your .cpp file such as
qml->setContextProperty("AppName", this);
01-05-2013 05:17 AM
Thank you for your reply!
So there is no way without using C++?
I am using QML together with Python (http://blackberry-py.microcode.ca )
I am not planing to switch to C++ just because of the clipboard. I know from other Systems (Nokia N9, Harmattan) that in general it is possible to access the clipboard from QML directly.
I now implemented the share functionality. Would be cool if the clipboard also would be added to that as a target.
01-05-2013 05:32 AM
That's the only way I know how to access the clipboard, it should be possible to convert the .cpp portions of that code to python & access it that way
01-24-2013 09:12 PM
01-26-2013 04:31 PM
That sounds great.
Please let me know when you get it working.
How are you using Python?
I am using BBTart (https://twitter.com/search?q=%23BBTart)
01-27-2013 03:10 PM
I'm using BB Tart as well. I just contributed the clipboard class to the repo. peter9477 and I are the lead contributors to the project, him being more lead than I!
http://hg.microcode.ca/blackberry-py/commits/93543