2D Toolkit Forum

2D Toolkit => Support => Topic started by: Martin on September 04, 2013, 02:11:46 am

Title: Closing dropdown with script (tk2dUIDropDownMenu)
Post by: Martin on September 04, 2013, 02:11:46 am

I could not find it in the documentation, is that something possible? I tried to use CollapseList() but nothing happen.
Title: Re: Closing dropdown with script (tk2dUIDropDownMenu)
Post by: gary-unikronsoftware on September 04, 2013, 01:44:27 pm
Hi Martin,

I'm not sure exactly what you did with 'CollapseList' but I have managed to get it working.  I just created a simple script that will collapse the list when 'x' is pressed:

Code: [Select]
public class DropDownMenuCollapse : MonoBehaviour {

public tk2dUIDropDownMenu ddm;

void Update ()
{
if(Input.GetKey("x"))
{
ddm.CollapseList();
}
}
}

Bear in mind that in tk2dUIDropDownItem, CollapseList is a private function so in order to make it work like in the example you will need to change it to public.

Hope this helps.
Title: Re: Closing dropdown with script (tk2dUIDropDownMenu)
Post by: Martin on September 04, 2013, 08:49:20 pm
Yep, that works! Thanks :)

I'm using code on a collider to close the dropdown if the user click outside of the dropdown. Any chance CollapseList() to be made public on future release?