Author Topic: PopUpList  (Read 4865 times)

Antiloco

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
PopUpList
« on: January 09, 2014, 04:15:09 AM »
Hi all,

I'm using UIPopUpList with some item (item1,item2,item3).
I have the necessity to show popup with the value set to empty, the first time that I show this control.
I set UIPopUpList.value="" and works fine, but the when i click on popup to make a choice,  Highlight sprite is shown outside item list area.
I have looked UIPopUpList.cs code at Onclick method, and I understand that happen because empty value doesn't  matches any values in item list.

TO solve this I have modified script in  this way

// Move the selection here if this is the right label            
   if (mSelectedItem == s || i==0)
      Highlight (lbl, true);

adding OR with i variable , I highlight the first item if there isn't  correspondence with popup value and popup list.

it is the correct way or is there another solution?


Thanks



« Last Edit: January 09, 2014, 08:18:18 AM by Antiloco »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: PopUpList
« Reply #1 on: January 09, 2014, 07:15:46 PM »
It sounds fine, but I can't check right now as I'm on vacation.

Antiloco

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: PopUpList
« Reply #2 on: January 29, 2014, 03:01:27 AM »
I have recently updated my NGUI version and , obviously , the update has overwritten my changes in UIPopList.cs
Is there a way to obtain the same result  without change UIPopList.cs  script?

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: PopUpList
« Reply #3 on: January 29, 2014, 09:26:23 AM »
The popup list isn't meant to have the selected item's value be nothing. Even with your change, it breaks controller-based input. No selected item, what do up/down arrows do? I suggest always defaulting to the first item in the list instead.

Add this right above the "// Run through all items and create labels for each one"
  1.                         // Ensure we have a valid selection
  2.                         if (string.IsNullOrEmpty(mSelectedItem) && items.Count > 0)
  3.                                 mSelectedItem = items[0];

That said... I'll make some changes to make it possible to do what you're trying to do in the next release.