Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 125
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C
My Carrier: none
Accepted Solution

clipboard

Will there be clipboard support? I would like to read/write to the cut and paste buffer. A user could then for instance select text in any app, then start my app, which would process that text, and put the result back on the clipboard. Or it could put an image on the clipboard that the user could then use in another app.

Retired
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: clipboard

Hey there,

 

Unfortunately this is not yet currently supported;

 

Martin

 

Highlighted
Developer
Posts: 280
Registered: ‎07-25-2008
My Device: Passport

Re: clipboard

For a more useful answer, I'll ammend that by saying that the Qt-friendly BB10 APIs do not currently provide Clipboard support, and I'm not sure if Qt's own clipboard APIs are working on BB10 yet.

 

However...  QNX itself does have a clipboard API, and it does actually work.  For a very brief example, here's how you take a QString and stick it in the clipboard:

 


#include <clipboard/clipboard.h>

 

void copyText(QString text) {

    if(empty_clipboard() == 0) {
        QByteArray data = text.toUtf8();
        set_clipboard_data("text/plain", data.size(), data);
    }
}


I suggest spending some time investigating clipboard.h for additional documentation on what you can use it for.

Developer
Posts: 125
Registered: ‎06-19-2012
My Device: PlayBook + Red Z10 + BB10 Dev Alpha C
My Carrier: none

Re: clipboard

Thanks! That's what I was looking for. And do you happen to know which library I should link against?

Developer
Posts: 280
Registered: ‎07-25-2008
My Device: Passport

Re: clipboard

Oh yeah, the one bit I forgot :-)

 

Its (quite obviously) named libclipboard.

 

So I added "LIBS += -lclipboard" to my project's .pro file.

Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: clipboard

Thanks for sharing this! Smiley Happy

--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Developer
Posts: 296
Registered: ‎02-14-2012
My Device: BlackBerry Passport / Nokia N950
My Carrier: -

Re: clipboard

[ Edited ]

This solution is not very well working. My app is at example only able to read the clipboard data while it is in the foreground and there is no Signal emittet if there are changes.

 

Polling the clipboard to watch for changes is not a very good solution, too. Smiley Sad

 

Are there any kind of information when QClipboard will get supported?