Author Topic: UIPopupList as a menu  (Read 2937 times)

Matt

  • Guest
UIPopupList as a menu
« on: April 22, 2012, 12:37:03 AM »
I purchased NGUI a few weeks back and am really enjoying using it so far.

I'm trying to create a menu using the popup list and have run into a problem where the previous selected item is being remembered - when I attempt to select this item a second time immediately afterward, no event is fired.

i.e. one of the menu options is "Help (H)" to show a help dialog. I click on the button labeled "Menu" which displays the popup list, then select "Help (H)" to display the help dialog. I then close the dialog by clicking on the "X" in the top right corner.

This works well, however if I repeat the action a second time, the list thinks that "Help (H)" already selected and the dialog doesn't open since the event is not being triggered. I tried setting "selected" to null, however that triggers an exception.

My temporary workaround for this is to make mSelectedItem public, and set it to false which creates the behavior I want - obviously not a good or long term solution :)

Is there currently a good and simple way to either clear the selected item or prevent the selected item from being retained?
« Last Edit: April 22, 2012, 12:42:54 AM by Matt »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList as a menu
« Reply #1 on: April 22, 2012, 01:43:14 AM »
You mention that you're trying to create a menu... are you using a menu template to start with? I'm kind of confused by you mentioning clicking on a button and displaying a popup list.

Matt

  • Guest
Re: UIPopupList as a menu
« Reply #2 on: April 22, 2012, 02:38:41 AM »
Yes that's right. I used the "Popup Menu" template.

By "button" I mean the Label and SlicedSprite background which are automatically generated by the template.
« Last Edit: April 22, 2012, 02:43:05 AM by Matt »