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:
UICamera.selectedObject = mySlot.gameObject;
But that didn't work: since the focus of the UICamera is not null the popup menu does not close. So I tried:
UICamera.selectedObject = null;
UICamera.selectedObject = mySlot.gameObject;
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?