Thread Tools Display Modes
05/01/14, 11:54 AM   #1
Grischu
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5
fail to change width of a dropdown Control

I create a dropdown controll and try to create it with this code


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

dropdown.SetWidth(100)
or

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.

Last edited by Grischu : 05/01/14 at 11:59 AM.
  Reply With Quote
05/01/14, 01:32 PM   #2
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Most control functions expect the object as first parameter.

So either
obj.SetWidth(obj, 100)
or
obj:SetWidth(100)
  Reply With Quote
05/01/14, 02:05 PM   #3
ingeniousclown
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 122
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.
  Reply With Quote
05/02/14, 01:36 AM   #4
Grischu
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5
Now i take the ZO_ComboBox and all work fine. Thanks
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » fail to change width of a dropdown Control


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