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: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T
Accepted Solution

Paste Text In Clipboard

[ Edited ]

Hello

 

I have a problem with the paste text.

 

Using this code:

void ApplicationUI::PasteText(const QByteArray &text)
{
	bb::system::Clipboard clipboard;
	QByteArray data = clipboard.value("text/plain");
	if (!data.isEmpty()) {
	    // process data from clipboard
	}

	    bb::system::SystemToast *toast = new SystemToast(this);
	    toast->setBody("Paste!");
	    toast->show();

}

 

But do not work!

 

The copy is run

 

 

I need when click the paste, Paste the text in TextArea

I think the problem in c++

 

Any solution?

Thanks

Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Re: Paste Text In Clipboard

Up 4 Help!

Retired
Posts: 85
Registered: ‎05-25-2012
My Device: Limited Edition Z10
My Carrier: Bell

Re: Paste Text In Clipboard

What is not working?  Is the method not called?  Do you see the toast message that you create?

Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Re: Paste Text In Clipboard

@erahnenfuehrer

 

The paste text in TextArea.

No I called the method.

Yes I see:

 

Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Re: Paste Text In Clipboard

Help ):

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Paste Text In Clipboard

Okay I'll step in, but not with the answer. Smiley Wink

 

The reason I haven't answered is because I'm puzzled why you would be using the clipboard to do this when it's just a straight copy or is this just a test app for you?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Paste Text In Clipboard

Also what debugging of this problem have you done by yourself?

 

For instance;

 

Is the passed in bytearray correct?

Is it coming from C++ or QML?

 

At least show the code where you copy from the label to the clipboard?

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 Limited Edition and Dev Alpha C
My Carrier: Movistar-Venezuela

Re: Paste Text In Clipboard

[ Edited ]

applicationui.cpp

void ApplicationUI::CopyToClipBoard(QString p_Url)
{
	m_ClipBoard.insert("text/plain", p_Url.toAscii());
}

 applicationui.hpp

public:
ApplicationUI(bb::cascades::Application *app);
virtual ~ApplicationUI(){ }
bb::system::Clipboard m_ClipBoard;
    Q_INVOKABLE void CopyToClipBoard(QString p_Url);


public slots:
 
    void changeText(QUrl p_Url);

 main.qml

import bb.cascades 1.0
import bb.system 1.0

......
Label{
id: labelID
 contextActions: [
    ActionSet {
     actions: ActionItem {
     title: "Copy"
     onTriggered: {
     app.CopyToClipBoard(labelID.text)
      copiedToast.show()
        }
           }
                }
     ]
}
 attachedObjects: [
 
        SystemToast {
            id: copiedToast
            body: "Copied to clipboard"
        }
    ]

 


Follow me in Twitter:

@Marcossit

BBM Channel:

MarcossitDev: C0002C366  

DeviceSuite For BlackBerry 10:

Link to Download DeviceSuite:

Support was successful? Accept as Solution and click on:


Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 Limited Edition and Dev Alpha C
My Carrier: Movistar-Venezuela

Re: Paste Text In Clipboard

[ Edited ]

It's like I'm using it in my application. Smiley Very Happy


Follow me in Twitter:

@Marcossit

BBM Channel:

MarcossitDev: C0002C366  

DeviceSuite For BlackBerry 10:

Link to Download DeviceSuite:

Support was successful? Accept as Solution and click on:


Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Re: Paste Text In Clipboard

@BBSJdev

 

 

I made this sample for I need to another app.

 

I have tried more than a code.

 

 

Button {
            text: "Copy!"
            onClicked: {
                _app.CopyText(textcopy.text);
            }
            horizontalAlignment: HorizontalAlignment.Center
        }

 

*Note: I don't copy text from label to another label.

I need paste text from clipboard.