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
Developer
klz
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Sharing not from Context Menu

 Hello everyone,

 

Sorry for the stupid question, but it looks like my brain got tired. So I need to share some text not form context menu, but by clicking a button. So in attachedObjects  I have

 

            Invocation {
              id: invoke
              query: InvokeQuery {
                mimeType: "text/plain"
                data: app.getText //because it should be QByteArray
                }
            }

 

and than call it 

            onClicked: {
                invoke.trigger("bb.action.SHARE");
            }

 BUT for some reasons there is no pre-set text. What am I doing wrong?

 

Any help would be appreciated. 

 

 

 

 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Sharing not from Context Menu

[ Edited ]

It's a bit buggy. It's simpler to share from C++ code:

 

On button click:

InvokeQuery *query = InvokeQuery::create()
    .data(displayString.toUtf8())
    .mimeType("text/plain")
    .invokeActionId("bb.action.SHARE");
invocation_ = Invocation::create(query)
    .parent(this);
                                                                                          
QObject::connect(invocation_, SIGNAL(armed()), this, SLOT(invocation_armed()));
QObject::connect(invocation_, SIGNAL(finished()), invocation_, SLOT(deleteLater()));

 

void CalculatorPage::invocation_armed()
{
        qDebug("Invocation armed");
        invocation_->trigger("bb.action.SHARE");
}

 

upd:

I've just noticed that brackets are missing in getText() function call. Could you try adding them and see if it helps?

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
Developer
klz
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: Sharing not from Context Menu

Zmey,

 

No, brackets won't help. I've just replaced my method with getText when writing the post. If i forgot a brackets I would see that in console. Will try your c++ implementation.

 

Thanks! 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Please use plain text.