Problem in ItemList

Post here if you want to help developing something for FAF.

Problem in ItemList

Postby Xinnony » 10 Dec 2013, 13:55

Hi all, i have a problem for get the selected item in itemlist.

Code: Select all
...
PresetList = ItemList(dialog2)
   PresetList:SetFont(UIUtil.bodyFont, 14)
   PresetList:ShowMouseoverItem(true)
   PresetList.Width:Set(210)
   PresetList.Height:Set(310)
   LayoutHelpers.AtLeftIn(PresetList, dialog2, 10)
   LayoutHelpers.AtTopIn(PresetList, dialog2, 38)
   UIUtil.CreateVertScrollbarFor2(PresetList)
   --
   LOAD_PresetProfils_For_InfoList()
   PresetList.OnClick = function(self)
      LOG('ONE CLICK > '..PresetList:GetSelection())
      AddChatText('ONE CLICK > '..PresetList:GetSelection())
   end
...

PresetList:GetSelection() return ALWAYS '-1' index, this is my problem.

Code: Select all
function LOAD_PresetProfils_For_InfoList()
   PresetList:AddItem('item1')
   PresetList:AddItem('item2')
   PresetList:AddItem('item3')
   PresetList:AddItem('item4')
end
User avatar
Xinnony
Contributor
 
Posts: 551
Joined: 19 Feb 2012, 02:49
Has liked: 70 times
Been liked: 34 times
FAF User Name: Xinnony

Re: Problem in ItemList

Postby Xinnony » 10 Dec 2013, 14:50

Fixed ! (thanks Domino)

In OnClick, added SetSelection.

PresetList.OnClick = function(self, row)
PresetList:SetSelection(row)
LOG('ONE CLICK > '..PresetList:GetSelection())
AddChatText('ONE CLICK > '..PresetList:GetSelection())
end
User avatar
Xinnony
Contributor
 
Posts: 551
Joined: 19 Feb 2012, 02:49
Has liked: 70 times
Been liked: 34 times
FAF User Name: Xinnony


Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest