ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   fail to change width of a dropdown Control (https://www.esoui.com/forums/showthread.php?t=1307)

Grischu 05/01/14 11:54 AM

fail to change width of a dropdown Control
 
I create a dropdown controll and try to create it with this code


Quote:

validChoices= BB.CharacterListe()
local dropdown = WINDOW_MANAGER:CreateControlFromVirtual(controlName.."ToonName", LeftFrame, "ZO_Options_Dropdown")
BB.dropdown=dropdown
dropdown:ClearAnchors()
dropdown:SetAnchor(TOP, toonlabel, BOTTOM, 0, 1)
dropdown:SetHidden(false)
dropdown.text = "Toon"
dropdown.valid = validChoices


local dropmenu = ZO_ComboBox_ObjectFromContainer(GetControl(dropdown, "Dropdown"))
ZO_PreHookHandler(dropmenu.m_selectedItemText, "OnTextChanged", function(self)
if dropmenu.m_selectedItemData then
selectedName = dropmenu.m_selectedItemData.name
dropmenu.m_selectedItemText.SetText(self, selectedName)
BB.SetToon(selectedName)
end
end)
dropdown:SetHandler("OnShow", function()
dropmenu:SetSelectedItem(validChoices)
end)

local function OnItemSelect(_, name, choice)
BB.SetToon(name)
end

for i=1,#validChoices do
local entry = dropmenu:CreateItemEntry(validChoices[i], OnItemSelect)
dropmenu:AddItem(entry)
end
i tried it with

Quote:

dropdown.SetWidth(100)
or

Quote:

local childs = dropdown.GetChildren()
for x, obj in pairs(childs) do
obj.SetWidth(100)
end
the last one raises a error, the other one has no effect.

Can anyone help me out, please.

Iyanga 05/01/14 01:32 PM

Most control functions expect the object as first parameter.

So either
obj.SetWidth(obj, 100)
or
obj:SetWidth(100)

ingeniousclown 05/01/14 02:05 PM

The template you are using, "ZO_Options_Dropdown" is not the dropdown control itself. It is a wrapper control that contains a label and a dropdown box laid out horizontally.

You need to get the actual dropdown control from your wrapper control.

I suggest you use "/zgoo mycontrolname" to look through the children of the wrapper control and figure out exactly what you need to extract.

Also, as a side-note you should probably use ZO_ComboBox instead since it doesn't have the unnecessary label, but I still think you'd need to extract the dropdown from it in the same way.

Grischu 05/02/14 01:36 AM

Now i take the ZO_ComboBox and all work fine. Thanks


All times are GMT -6. The time now is 03:39 AM.

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