Author Topic: bug in UIInput  (Read 8502 times)

jmclaren

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
bug in UIInput
« on: February 19, 2013, 10:38:44 AM »
When you type more characters into a Input widget than the lineWidth of the child UILabel with single line, centre pivot, the whole UILabel teleports off to the right. observed in 2.3.1 and 2.3.3h

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: bug in UIInput
« Reply #1 on: February 19, 2013, 08:53:22 PM »
That's because only left-aligned input fields are supported. This is enforced by the input creation process -- when you create a new input field, it's set to be left-aligned. You've had to have changed it to be center-aligned yourself. Change it back.

jmclaren

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: bug in UIInput
« Reply #2 on: February 21, 2013, 09:28:59 AM »
We would prefer to be able to use centre alignment too, is this possible for a future release?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: bug in UIInput
« Reply #3 on: February 21, 2013, 11:02:00 PM »
Perhaps in the future, sure. You're welcome to submit a patch for it! ;)

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Re: bug in UIInput
« Reply #4 on: April 03, 2013, 10:35:37 PM »
  1. diff NGUI-2.5.1/Assets/NGUI/Scripts/UI/UIInput.cs Project/Assets/NGUI/Scripts/UI/UIInput.cs
  2. 468c468,483
  3. <
  4. ---
  5. >                                       else if (mPivot == UIWidget.Pivot.Center)
  6. >                                       {
  7. >                                               label.pivot = UIWidget.Pivot.Right;
  8. >                                               pos.x -= label.lineWidth * 0.5f;
  9. >                                       }
  10. >                                       else if (mPivot == UIWidget.Pivot.Top)
  11. >                                       {
  12. >                                               label.pivot = UIWidget.Pivot.TopRight;
  13. >                                               pos.x -= label.lineWidth * 0.5f;
  14. >                                       }
  15. >                                       else if (mPivot == UIWidget.Pivot.Bottom)
  16. >                                       {
  17. >                                               label.pivot = UIWidget.Pivot.BottomRight;
  18. >                                               pos.x -= label.lineWidth * 0.5f;
  19. >                                       }
  20.  

I realized after making this change that right-aligned labels aren't supported either, or I probably would have made this slightly more elegant.  Silly me.  Left that as an exercise for the reader.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: bug in UIInput
« Reply #5 on: April 04, 2013, 04:30:06 AM »
This also assumes lineWidth was set.

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Re: bug in UIInput
« Reply #6 on: April 04, 2013, 11:59:46 PM »
So does the existing code just above where that's added.  :P

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: bug in UIInput
« Reply #7 on: April 05, 2013, 11:59:18 AM »
True!