Frozen In Ice
Emperor
- Joined
- Jun 30, 2007
- Messages
- 1,536
I'm trying to add a button to the diplomacy deal view UI, but I keep getting errors whenever I try to test it in-game.
So I added a button entry under the LeftRightList instance like so:
And then in the lua file under the createHorizontalGroup function that creates the LeftRightList instances I added a register call back line like I had seen elsewhere in the code:
I thought this line would tell the game that when left clicking the button of a leftRightList, it should run the function OnToggleCollapseGroup for that list.However, when I try running the game, the diplomacy deal view isn't created properly as none of the tradable items are even listed.
What am I missing when it comes to adding buttons?
So I added a button entry under the LeftRightList instance like so:
Code:
<Instance Name="LeftRightList">
<Stack ID="List" Size="parent, 0">
<Grid Style="ColumnHeader" ID="Title" Size="parent-4,26" Offset="0,0" Anchor="C,T" Color="25,25,25,200">
<Button ID="CollapseStackButton" Anchor="L,C" Offset="0,0" Size="16,16" Texture="Controls_ExpandButton2"/>
<Label ID="TitleText" Anchor="C,C" Offset="4,0" Style="HeaderSmallCaps" Hidden="false" Color0="89,85,85"/>
</Grid>
<Stack ID="ListStack" StackGrowth="Right" Anchor="L,T" WrapWidth="parent">
</Stack>
</Stack>
</Instance>
Code:
function CreateHorizontalGroup(rootStack : table, title : string)
local iconList = ms_LeftRightListIM:GetInstance(rootStack);
if (title == nil or title == "") then
iconList.Title:SetHide(true); -- No title
else
iconList.TitleText:LocalizeAndSetText(title);
end
iconList.List:CalculateSize();
iconList.List:ReprocessAnchoring();
Controls.CollapseStackButton:RegisterCallback( Mouse.eLClick, function() OnToggleCollapseGroup(iconList); end);
return iconList;
end
What am I missing when it comes to adding buttons?