Author Topic: Popup List Default no more send OnChange  (Read 1519 times)

armitage1982

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 15
    • View Profile
Popup List Default no more send OnChange
« on: July 15, 2015, 09:51:49 AM »
Using NGUI 3.9.0b Popup List Default selection won't show up.

However, the default item is correctly selected when opening the widget.

In older version an OnChange() event was triggered at first (allowing OnCurrentSelection() to refresh the label).

Is this the new Default design ?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup List Default no more send OnChange
« Reply #1 on: July 16, 2015, 10:55:46 AM »
Thanks, you can fix it locally by changing UIPopupList's Start() function to this:
  1.         void Start ()
  2.         {
  3.                 // Auto-upgrade legacy functionality
  4.                 if (textLabel != null)
  5.                 {
  6.                         EventDelegate.Add(onChange, textLabel.SetCurrentSelection);
  7.                         textLabel = null;
  8. #if UNITY_EDITOR
  9.                         NGUITools.SetDirty(this);
  10. #endif
  11.                 }
  12.  
  13.                 // Automatically choose the first item
  14.                 if (Application.isPlaying)
  15.                 {
  16.                         if (string.IsNullOrEmpty(mSelectedItem) && items.Count > 0)
  17.                                 mSelectedItem = items[0];
  18.                         if (!string.IsNullOrEmpty(mSelectedItem))
  19.                                 TriggerCallbacks();
  20.                 }
  21.         }

armitage1982

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 15
    • View Profile
Re: Popup List Default no more send OnChange
« Reply #2 on: July 17, 2015, 05:19:07 AM »
Thanks, I saw your update this morning ;-)

I should definitely "Turn notification on when you post or reply to a topic" by default :P