Hello Guest

Author Topic: Closing dropdown with script (tk2dUIDropDownMenu)  (Read 4338 times)

Martin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Closing dropdown with script (tk2dUIDropDownMenu)
« 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.

gary-unikronsoftware

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 74
    • View Profile
Re: Closing dropdown with script (tk2dUIDropDownMenu)
« Reply #1 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.

Martin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Closing dropdown with script (tk2dUIDropDownMenu)
« Reply #2 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?