View Single Post
04/28/14, 07:09 AM   #4
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
I don't know about the WoW api similarity but I can help you by showing you how i would do it:

First to define some button in you XML (inside <Controls> element, inside <TopLevelControl>):
Code:
<Button name="$(parent)OpenDropdown" inherits="ZO_DropdownButton">
   <Anchor .../>
   <OnMouseDown>
      ToggleMyDropdown(self)
   </OnMouseDown>
</Button>
Then in your lua code:

Lua Code:
  1. local hidden = true
  2. function ToggleMyDropdown(control)
  3.    hidden = not(hidden)
  4.    if hidden then
  5.       ClearMenu()
  6.    else
  7.       ClearMenu()
  8.       AddMenuItem("Item1", function() d("item1") end)
  9.       AddMenuItem("Item2", function() d("item2") end)
  10.       AddMenuItem("Item3", function() d("item3") end)
  11.       SetMenuHiddenCallback( function() hidden = true end )
  12.       ShowMenu(cotrol,1)
  13.    end
  14. end
This is not working example so you should figure out where to put the button, what attributes to set and so on.

Edit:
the GUI section is here already for some time now

Edit2:
added SetMenuHiddenCallback()

Last edited by Harven : 04/28/14 at 08:35 AM.
  Reply With Quote