Author Topic: Forcing a UIPopupList to close?  (Read 2225 times)

Seith

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
    • View Profile
    • SeithCG
Forcing a UIPopupList to close?
« 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.
« Last Edit: March 15, 2014, 06:44:10 AM by Seith »
SeithCG.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Forcing a UIPopupList to close?
« Reply #1 on: March 15, 2014, 05:55:20 PM »
UICamera.selectedObject = null;

Popup closes itself when it loses the selection.

Seith

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
    • View Profile
    • SeithCG
Re: Forcing a UIPopupList to close?
« Reply #2 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?
SeithCG.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Forcing a UIPopupList to close?
« Reply #3 on: March 16, 2014, 12:26:39 PM »
popupObject.SendMessage("OnSelect", false);

Seith

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
    • View Profile
    • SeithCG
Re: Forcing a UIPopupList to close?
« Reply #4 on: March 17, 2014, 04:04:13 PM »
That works. Thanks ArenMook!
SeithCG.com