View Single Post
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:	597
Size:	465.1 KB
ID:	75  Click image for larger version

Name:	Screenshot_20140405_054751.jpg
Views:	623
Size:	359.6 KB
ID:	76  
  Reply With Quote