Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Seith on March 15, 2014, 05:55:29 AM

Title: Forcing a UIPopupList to close?
Post by: Seith on March 15, 2014, 05:55:29 AM
Hello, I'm trying to get a UIPopupList to close via scripting. So far the only thing I found is ".isOpen" but that can only be queried. Is there a way to actually close the popup? Thanks...

Just to be clear: this is to be able to close the popup without actually validating the current selection, in effect canceling the popup action.
Title: Re: Forcing a UIPopupList to close?
Post by: ArenMook on March 15, 2014, 05:55:20 PM
UICamera.selectedObject = null;

Popup closes itself when it loses the selection.
Title: Re: Forcing a UIPopupList to close?
Post by: Seith on March 16, 2014, 06:02:43 AM
Thanks ArenMook. However that doesn't quite work in my case: in my inventory system I have slots which are UIButtons and when I activate one by pressing the gamepad's B button then the UIPopupMenu appears.

If I use the code you gave me the popup menu indeed disappears but the focus on my inventory slot is also lost. I tried doing:

  1. UICamera.selectedObject = mySlot.gameObject;
  2.  

But that didn't work: since the focus of the UICamera is not null the popup menu does not close. So I tried:

  1. UICamera.selectedObject = null;
  2. UICamera.selectedObject = mySlot.gameObject;
  3.  
But that doesn't work either because although the popup menu does close, the camera focus does not go back to slot/button (it remains null).

So my question is: how can I close the popup menu without losing the focus on the button which hosts the popup menu?
Title: Re: Forcing a UIPopupList to close?
Post by: ArenMook on March 16, 2014, 12:26:39 PM
popupObject.SendMessage("OnSelect", false);
Title: Re: Forcing a UIPopupList to close?
Post by: Seith on March 17, 2014, 04:04:13 PM
That works. Thanks ArenMook!