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
Posts: 24
Registered: ‎05-14-2014
My Device: Blackberry-Z10
My Carrier: Vodafone
Accepted Solution

Simulating touch gestures for Blackberry Z10

I would like to simulate the touch gesture in Blackberry Z10. In the QML there are keywords such as onClicked, onTriggered etc. and there is action accordingly. But would it be possible without touching simulating the same onClicked, onTrigger actions?

Can anyone present a sample code for the same where a touch gesture is necessary for an action and same touch gesture is then simulated in the /src or .qml files?

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

Re: Simulating touch gestures for Blackberry Z10

The answer to this really is no or rather it's not easy would be more accurate, there is no API for this.

 

If you are wanting this for testing purposes then take a look at this...

 

http://supportforums.blackberry.com/t5/Testing-and-Deployment/FOSS-Automated-Testing-for-BB10-Cascad...


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.
Retired
Posts: 85
Registered: ‎05-25-2012
My Device: Limited Edition Z10
My Carrier: Bell

Re: Simulating touch gestures for Blackberry Z10

You could set up your code so that the onTouch slot and your onSimulatedTouch slot call the same function.

Developer
Developer
Posts: 24
Registered: ‎05-14-2014
My Device: Blackberry-Z10
My Carrier: Vodafone

Re: Simulating touch gestures for Blackberry Z10

Could you show an example for code for the same?

Let say for example 'Send' button which trigger an event to send an email when touched. How would simulated sample code look like in this case?

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

Re: Simulating touch gestures for Blackberry Z10

It depends how your code is structured, and if you need to use a signal, or whether you want to call the function directly.  If your UI is written in QML, but the logic is in C++ it may look like this.

 

QML:

 

 Button
        {
            text: "Click Me!"
            onClicked:
                {
                    _app.buttonClicked();
                }
        }

 And in your C++:

 

void ApplicationUI::simulateClick()
{
    buttonClicked();
}

void ApplicationUI::buttonClicked()
{
    qDebug() << "CLICK!";
}

 And don't forget to set the context property so you can access C++ calls in your QML:

 

    // Create scene document from main.qml asset, the parent is set
    // to ensure the document gets destroyed properly at shut down.
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    qml->setContextProperty("_app", this);

 

Developer
Developer
Posts: 24
Registered: ‎05-14-2014
My Device: Blackberry-Z10
My Carrier: Vodafone

Re: Simulating touch gestures for Blackberry Z10

I managed to do it!  I needed to do without any GUI just start the app and trigger sending receiving emails. Its basically using the 'connect'  (Qt) in the constructor itself and then it functioned as I want it to.

Thanks for the explanation.