Thread Tools Display Modes
06-30-12, 10:20 AM   #1
sigEleven
A Murloc Raider
Join Date: Jun 2012
Posts: 7
Unhappy Trouble initializing UIDropDownMenu from XML

Hey All, hoping someone can lend me a hand here.

I've been trying to wrap my head around drop down menus for a while now, and it's surprisingly difficult. After following multiple examples and tutorials that don't work, I've hacked together some operable code to get my drop downs working.

However, I'd like to create the dropdowns in XML, and not clutter up my LUA code with it. The problem I'm noticing right now is that I cannot initialize the dropdowns correctly in XML.

This does not work correctly (I end up with a blank drop down box that says "Custom" with no options):

Code:
<Button name="BName" parent="Parent_Frame" inherits="UIDropDownMenuTemplate"> 
   <Scripts>
      <OnLoad>  UIDropDownMenu_Initialize(BName, BName_initialize)</OnLoad>
    </Scripts>
</Button>

However, this works fine in LUA, when placed in the drop down's parent frame onload function.
Lua Code:
  1. UIDropDownMenu_Initialize(BName, BName_initialize)

Hopefully I'm just missing something simple, anybody have any idea what's up?

Last edited by sigEleven : 06-30-12 at 10:46 AM.
  Reply With Quote
06-30-12, 10:40 AM   #2
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Not sure if that's the problem, but the first argument of your function in your XML code is not the same as in your lua code. BName and BName_Filter.
  Reply With Quote
07-01-12, 02:00 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
(1) XML is hideous and ugly, and far more cluttered than any Lua.

(2) Is your "BName_initialize" function already loaded when your XML loads? If not (eg. if you are loading the XML file first, and then the Lua file where the function is defined) then that is your problem.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-03-12, 03:52 PM   #4
sigEleven
A Murloc Raider
Join Date: Jun 2012
Posts: 7
Thanks for the replies,

Haleth: I caught that, and did an edit, but I guess you got your reply in first. I did confirm the function is correct.

Phanx: I agree; call it an OCD thing, but I'd like all my elements statically created in XML, in a separate file. Confirmed functions (lua file) loading first, then xml.

Has anybody been able to duplicate this, or have any other ideas?
__________________
There are 10 types of people who exist in this world, those who get it, and those who don't.
  Reply With Quote
07-03-12, 04:06 PM   #5
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by sigEleven View Post
Phanx: I agree; call it an OCD thing, but I'd like all my elements statically created in XML, in a separate file.
...and needlessly inserting their names into the global namespace.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
07-03-12, 04:10 PM   #6
sigEleven
A Murloc Raider
Join Date: Jun 2012
Posts: 7
Yeah, because that bit of memory allocation is going to kill people's machines. Thanks for the help Torhal.
__________________
There are 10 types of people who exist in this world, those who get it, and those who don't.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trouble initializing UIDropDownMenu from XML


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off