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
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany
Accepted Solution

Password textfield not returning text

I have a textfield defined:

TextField {
  id: passwordField
   text: password
   hintText: qsTr("Password") + Retranslate.onLanguageChanged
   inputMode: TextFieldInputMode.Password
}

password is a property defined above, to allow access to the text from outside:

property string password

 i want to save the password on click on a button, and check for empty values:

if ("" != passwordField.text) {
  //call save in c++
  saveToast.show()
} else {
  console.log("passwordField.text" + passwordField.text)
}

The field shows the correct value, a number of '*' equal to the password set, but the save check is always wrong and on the console the output is empty:

Debug: passwordField.text

 

I can enter any text i want in the field, the text attribute seems to be always empty.

 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Password textfield not returning text

Well, given the conditional, you're only executing that when it thinks it's empty, so you should not expect to see anything but "passwordField.text" in the console.

Why it is empty, that's another question altogether... You appear to have forced the text always to be the value of the "password" property. I think what you really wanted is to define that property as "property alias password: passwordField.text". At that point, I expect things would work.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Password textfield not returning text

Thanks, the alias property is indeed what i wanted to do.

for future reference, here is the documentation:
http://doc.qt.digia.com/qt/propertybinding.html
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Password textfield not returning text


simon_hain wrote:...
i want to save the password on click on a button, and check for empty values:

 


BTW: yxou can also use the Cascades Credentials Dialog where you can only go on if password isn't empty

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Password textfield not returning text

i am displaying a list of configured usernames/passwords in a dynamically created qml component.
i'll use the credentials dialog later, for example on a http 401.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.