Thread Tools Display Modes
04/22/14, 07:07 PM   #1
TheBelgarion
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
Updating Dropdown select new value

HI

i tried using LAM:AddDropdown() in my Setting Panel.

I wanted to change the value of a second Dropdown if i select something else in the first and even the dropdown prefix.

So i did a SetFunction on dropdown 1

Code:
BAM.selectItemTypeSetFunc = function(itemType)
    local dropdown = BAM.elements.secondDropdown
    local dropmenu = dropdown:GetNamedChild("Dropdown")
    BAM.dm = dropmenu
    dropdown.text = itemType
    dropmenu.m_comboBox.SetSelectedItem(BAM.defaultBagGetFunc(itemType))
    dropmenu.m_comboBox.SelectItem(BAM.defaultBagGetFunc(itemType))
    ZO_OptionsWindow_InitializeControl(dropmenu)
    ZO_OptionsWindow_InitializeControl(dropdown)
end
the problem is with changing the selected value
dropmenu.m_comboBox.SetSelectedItem does not seem to work ( the value is the correct one checked that already )
even checked with zgoo dropmenu.m_comboBox looks like the right object, but cant change the selected Value somehow.

Not sure which method would be the correct Method to change the Selected Value on a LAM.Dropbox Object.


Any Ideas ?

thx a lot

TheBelgarion
  Reply With Quote
04/22/14, 10:32 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Should just be dropmenu:SetSelectedItem()
  Reply With Quote
04/23/14, 11:37 AM   #3
TheBelgarion
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
gonna try it out.

dropmenu:SetSelectedItem(BAM.defaultBagGetFunc(itemType))

user:/AddOns/BagsAndMore/BagsAndMore.lua:93: function expected instead of nil

Param should be "Bank" which is in the list of options.
no method with that name on dropmenu?

Which looks strange compared to the LAM code which uses that method
dropdown:SetHandler("OnShow", function() dropmenu:SetSelectedItem(getFunc()) end)



another think which bothers me - is this the right way to refresh the Dropbox e.g. repaint it with new text and values.

ZO_OptionsWindow_InitializeControl(dropdown)


or which would be the prefered way to repaint an Option?


thx
TheBelgarion

Last edited by TheBelgarion : 04/23/14 at 12:35 PM.
  Reply With Quote
04/23/14, 01:09 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Lua Code:
  1. dropmenu:ClearItems()

and then add new ones again to it using
Lua Code:
  1. for i=1,#tableOfChoices do
  2.     local entry = dropmenu:CreateItemEntry(tableOfChoices[i], callbackFunc)
  3.     dropmenu:AddItem(entry)
  4. end
  Reply With Quote
04/23/14, 01:32 PM   #5
TheBelgarion
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
Ok i finally try&error it ;-)

Code:
BAM.selectItemTypeSetFunc = function(itemType)
    BAM.currentType = itemType
    local dropdown = BAM.elements.selectItemDefaultBag
    local dropmenu = dropdown:GetNamedChild("Dropdown")
    dropdown.text = itemType
    bagId = (BAM.DATA.controlType[itemType].default.bag or 0) + 1
    dropmenu.m_comboBox:SelectItem(dropmenu.m_comboBox:GetItems()[bagId])
    ZO_OptionsWindow_InitializeControl(dropdown)
end
to select another Item in the dropdown.
  Reply With Quote
04/23/14, 03:47 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Why are you still doing it this way?
Lua Code:
  1. dropmenu.m_comboBox:SelectItem(dropmenu.m_comboBox:GetItems()[bagId])
  Reply With Quote
04/23/14, 05:11 PM   #7
TheBelgarion
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
because:

93: dropmenu:SetSelectedItem(BAM.defaultBagGetFunc(itemType))

user:/AddOns/BagsAndMore/BagsAndMore.lua:93: function expected instead of nil

there is no function SetSelectedItem on dropmenu i checked with /zgoo

or how else should i do it ?
  Reply With Quote
04/23/14, 07:17 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
My apologies, you were defining dropmenu incorrectly. Do this instead to define dropmenu:
Lua Code:
  1. local dropmenu = ZO_ComboBox_ObjectFromContainer(GetControl(dropdown, "Dropdown"))
  Reply With Quote
04/24/14, 08:14 AM   #9
TheBelgarion
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
Ok thx will try later.

One more Question about dropbox.

is there an option to make the Box scrollable?

Im using the dropdown to show all item Types and on none FullHD Screen it does not fit to screen but there is no option to scroll the content of the open Box ?

And I would like to put a "Prev" "Next" Button below, but in one like ? can I do that with LAM ?

thx a lot for your help!

Bel
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Updating Dropdown select new value

Thread Tools
Display Modes

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