user1296259
user1296259

Reputation: 521

How do you respond to tapping on a textfield only when you click up on Blackberry Cascades simulator in QML?

I am trying to figure out how to respond to the tapping on a textfield in Blackberry Cascades. Right now, I have this sort of code:

TextField {
    onFocusedChanged: {
        if (focused) {
            doStuff();
        }
    }
}

But this responds the moment you click on an item, but doesn't wait till you let go of the mouse in the simulator (or the equivalent in a real blackberry)

Upvotes: 1

Views: 2470

Answers (2)

SelvaRaman
SelvaRaman

Reputation: 218

Try this one

onTouch: {
  if (event.isUp()) {
    //do stuff here
  }
}

Upvotes: 0

RajaRaviVarma
RajaRaviVarma

Reputation: 2742

Try this code, this worked for me in Simulator. I don't have a blackberry device to check this.

TextField {
    id: field
    width: parent.width

    MouseArea {
        anchors.fill: parent
        onClicked:{ console.debug("Got click event received! \nSetting focus for TextField");  field.focus = true; }
    }
}

Upvotes: 2

Related Questions