ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   XML to Lua Conversion not working (https://www.esoui.com/forums/showthread.php?t=573)

Xrystal 04/04/14 10:53 PM

XML to Lua Conversion not working
 
2 Attachment(s)
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.

chase 04/05/14 03:41 AM

Off-topic:
May I ask why are you migrating to code from markup?

Xrystal 04/05/14 05:20 AM

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.

Seerah 04/05/14 09:51 AM

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...

Xrystal 04/05/14 10:29 AM

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.

Seerah 04/05/14 11:14 AM

Right, I was talking about when using Lua. :p


All times are GMT -6. The time now is 04:18 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI