How do I reset the value of a NGUI UIInput control that marked Is Password. If I set .text to "" I still see a bunch of ********** rather than the .defaultText.

Basically if the user types the wrong password during login, I want to clear the field and have is display the default text again.


If I click into the field and back out, the default text shows, but until I do that I get the **********.


// Show the Create dialog
public void ShowCreate() {

    username = loginUsername.text;
    createUsername.text = username;
    createPasswordA.text = "";
    createPasswordB.text = "";

Image: enter image description here

  • 1
    \$\begingroup\$ Could you show us your actual code? Because what you describe should just work. Set the my_uiinput.text = ""; should clear it just fine. \$\endgroup\$ – Bart Feb 6 '13 at 13:46
  • \$\begingroup\$ It might be that the widget doesn't have the focus. Could you try setting selected to true and see if that changes anything? i.e. createPasswordA.selected = true; \$\endgroup\$ – Bart Feb 7 '13 at 10:01
  • \$\begingroup\$ @Bart - write that as an answer. Had to add all three to make it work right: createPasswordB.selected = true; createPasswordA.selected = true; createUsername.selected = true; \$\endgroup\$ – Justin808 Feb 7 '13 at 17:28

Normally setting the text member to "" should clear the UIInput. However, for this to take effect, the widget does need to have the focus (selected needs to be true). If your widget does not immediately clear, you can set its focus manually.

In your case that would be:

createPasswordA.selected = true;
createPasswordB.selected = true;
createUsername.selected = true;

That should do the trick.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.