Author Topic: UIInput incorrectly right aligning with password  (Read 1839 times)

dlewis

  • Guest
UIInput incorrectly right aligning with password
« on: January 02, 2013, 08:04:04 PM »
There is a small problem with UIInput for passwords. Normally if the string is longer than the maximum width it will change the pivot to the right and it won't show all the characters on the left (clips the string). However if the input field is set to password it seems to be incorrectly calculating the length based off the hidden characters, not the displayed asterisks.

I thought I saw you mention this issue before and I thought it was merged in at some point. Anyway, here is my code that (roughly) fixes the issue. It would be good if this (or something similar/better) could be added in the next version.

bwlong line 403 in UIInput.cs
  1. if (isPassword)
  2. {
  3.         processed = "";
  4.         for (int i = 0; i < mText.Length; i++)
  5.         {
  6.                 processed += "*";
  7.         }
  8.        
  9.         if (selected)
  10.         {
  11.                 processed += Input.compositionString + caratChar;
  12.         }
  13. }

I tested this in a black project with a clean copy of NGUI (2.2.6c).

Cheers

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput incorrectly right aligning with password
« Reply #1 on: January 03, 2013, 02:15:11 AM »
I am fairly certain I already fixed it in 2.2.7... I'll push it out this weekend.

dlewis

  • Guest
Re: UIInput incorrectly right aligning with password
« Reply #2 on: January 06, 2013, 06:23:54 PM »
This is still not working as intended in 2.2.7c. Doing a diff on the UIInput file shows no changes to UpdateLabel().

Easiest way to repro is make a new Input widget, set password to true (on the input, not the label) and then just keep tying a with the game running until you see it visibly snap to the right.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput incorrectly right aligning with password
« Reply #3 on: January 06, 2013, 08:49:49 PM »
I see what you mean now. That indeed was not covered by the changes to the UILabel. I'll add your fix, thanks.

dlewis

  • Guest
Re: UIInput incorrectly right aligning with password
« Reply #4 on: January 07, 2013, 12:35:32 AM »
My fix still has a very small problem. Depending on the size of the label it will visibly move up to half a character to the right since one * will be half in and out. Not sure how to fix that (if it can be fixed).