Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: jmclaren on February 19, 2013, 10:38:44 AM

Title: bug in UIInput
Post by: jmclaren 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
Title: Re: bug in UIInput
Post by: ArenMook 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.
Title: Re: bug in UIInput
Post by: jmclaren 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?
Title: Re: bug in UIInput
Post by: ArenMook on February 21, 2013, 11:02:00 PM
Perhaps in the future, sure. You're welcome to submit a patch for it! ;)
Title: Re: bug in UIInput
Post by: ryan 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.
Title: Re: bug in UIInput
Post by: ArenMook on April 04, 2013, 04:30:06 AM
This also assumes lineWidth was set.
Title: Re: bug in UIInput
Post by: ryan on April 04, 2013, 11:59:46 PM
So does the existing code just above where that's added.  :P
Title: Re: bug in UIInput
Post by: ArenMook on April 05, 2013, 11:59:18 AM
True!