kev
kev

Reputation: 155

Clearing textfield blackberry

How do I clear the TextField in blackberry? Here's the qml:

Container {
                        horizontalAlignment: HorizontalAlignment.Center
                        verticalAlignment: VerticalAlignment.Bottom
                        leftPadding: 75
                        rightPadding: leftPadding
                        bottomPadding: 40

                    TextField {
                        id: tfComment
                        hintText: qsTr("add comment")
                        inputMode: TextFieldInputMode.Text
                        input {
                            submitKey: SubmitKey.Submit
                            onSubmitted: {
                                cppObj.onCommentSubmitClicked(tfComment.text, "");
                                lComment.text = tfComment.text;
                            }
                        }
                    }
                }

Container {
                        horizontalAlignment: HorizontalAlignment.Center
                        verticalAlignment: VerticalAlignment.Bottom
                        bottomPadding: 200
                        leftPadding: 20
                        rightPadding: leftPadding

                       Label {
                           id: lComment
                           verticalAlignment: VerticalAlignment.Bottom
                           horizontalAlignment: HorizontalAlignment.Center
                           text: cppObj.desc
                       }
                    } 

I want to clear the data entered to the TextField so there'll be room for me to comment another. How do I do that?

Upvotes: 0

Views: 310

Answers (2)

Hareen Laks
Hareen Laks

Reputation: 1505

Try this inside the onSubmitted handler:

tfComment.Text = ""

Upvotes: 1

Konrad Lindenbach
Konrad Lindenbach

Reputation: 4961

textField->resetText()

The documentation is here:

http://developer.blackberry.com/cascades/reference/bb__cascades__textfield.html

Upvotes: 2

Related Questions