Thread Tools Display Modes
04/04/14, 10:53 PM   #1
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
XML to Lua Conversion not working

I'm trying to convert this part of the XML file to Lua but so far no joy.
Lua Code:
  1. <Control name="$(parent)_ComboBoxZone" resizeToFitDescendents="true" mouseEnabled="true">
  2.     <Anchor point="TOPRIGHT" offsetX="-8" offsetY="15"/>
  3.         <OnInitialized>
  4.             ZO_ComboBox:New(self)
  5.         </OnInitialized>
  6.         <OnMouseUp>
  7.             ZO_ComboBox_DropdownClicked(self)
  8.         </OnMouseUp>
  9.         <Controls>
  10.             <Button name="$(parent)OpenDropdown" inherits="ZO_DropdownButton">
  11.               <Dimensions x="16" y="16" />
  12.               <Anchor point="TOPRIGHT"/>
  13.               <OnClicked>
  14.                   ZO_ComboBox_DropdownClicked(self:GetParent())
  15.               </OnClicked>
  16.            </Button>
  17.            <Label name="$(parent)SelectedItemText">
  18.                <Anchor point="RIGHT" relativeTo="$(parent)OpenDropdown" relativePoint="LEFT" offsetX="-3" />
  19.                </Label>
  20.            </Controls>
  21.         </Control>

I thought that it would covert to something like this but no joy.

Lua Code:
  1. tlw.ZoneList = WindowMgr:CreateControl(nil,tlw,CT_CONTROL)
  2.     tlw.ZoneList:SetAnchor(TOPRIGHT,tlw,TOPRIGHT,-8,15)
  3.     tlw.ZoneList:SetHandler("OnInitialized",function(self)
  4.         ZO_ComboBox:New(self)
  5.     end)
  6.     tlw.ZoneList:SetHandler("OnMouseUp",function(self)
  7.         ZO_ComboBox_DropdownClicked(self)
  8.     end)
  9.     tlw.ZoneList.Button = WindowMgr:CreateControlFromVirtual(nil,tlw,"ZO_DropdownButton")
  10.     tlw.ZoneList.Button:SetDimensions(16,16)
  11.     tlw.ZoneList.Button:SetAnchor(TOPRIGHT,tlw.ZoneList,TOPRIGHT,0,0)
  12.     tlw.ZoneList.Button:SetHandler("OnClicked",function(self)
  13.         ZO_ComboBox_DropdownClicked(self:GetParent())
  14.     end)
  15.     tlw.ZoneList.Caption = WindowMgr:CreateControl(nil,tlw,CT_LABEL)
  16.     tlw.ZoneList.Caption:SetFont("ZoFontGame")
  17.     tlw.ZoneList.Caption:SetAnchor(RIGHT,tlw.ZoneList.Button,LEFT,0,0)
  18.  
  19.     tlw.ZoneList.DropDown = ZO_ComboBox_ObjectFromContainer( tlw.ZoneList )
  20.     tlw.ZoneList.DropDown:SetSelectedItemFont( 'ZoFontWinH2' )   -------> Line 458
  21.     tlw.ZoneList.DropDown:SetDropdownFont( 'ZoFontHeader2' )
  22.     tlw.ZoneList.DropDown:SetSpacing( 8 )
  23.     tlw.ZoneList.DropDown:SetSelectedItem( tlw.ZoneList.DropDown.SelectedItem )

The screenshots attached show the display at the moment along with the error that is being reported. If someone, perhaps Pawkette who created the initial addon that I found this code in could explain if there was a way that they knew of coding it in Lua.

The one without the error is with the who UI code inside the XML, the second one is with everything except the combo boxes which don't seem to want to work.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140405_054427.jpg
Views:	576
Size:	465.1 KB
ID:	75  Click image for larger version

Name:	Screenshot_20140405_054751.jpg
Views:	598
Size:	359.6 KB
ID:	76  
  Reply With Quote
04/05/14, 03:41 AM   #2
chase
Join Date: Apr 2014
Posts: 3
Off-topic:
May I ask why are you migrating to code from markup?
  Reply With Quote
04/05/14, 05:20 AM   #3
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
I'm just more comfortable with lua code. If, of course it isn't possible, I'd simply use XML for everything for consistency. The other reason is because it helps me understand how it works better coming from a programming background rather than a markup background.

edit:
And also, it puts the frames generated in xml into the global table, which if unnecessary I would rather not do.

Last edited by Xrystal : 04/05/14 at 05:58 AM.
  Reply With Quote
04/05/14, 09:51 AM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Do you have a TopLevel control?

WINDOW_MANAGER:CreateTopLevelWindow("MainFrameName")


/edit: also, Zork says otherwise, but I haven't had much luck in ESO with giving frames nil for a name...
  Reply With Quote
04/05/14, 10:29 AM   #5
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Yeah, have a top level control. And if I use Lua I can use nil for control name but I suspect in the xml you would have to have a name so you can access it in your Lua code.

I've gone with putting it all back into the XML and currently working on how the combo boxes work together.
  Reply With Quote
04/05/14, 11:14 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Right, I was talking about when using Lua.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » XML to Lua Conversion not working


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