-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListview.lua
More file actions
44 lines (34 loc) · 1.56 KB
/
Listview.lua
File metadata and controls
44 lines (34 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
ClassicEraCensusListviewMixin = {}
function ClassicEraCensusListviewMixin:OnLoad()
self.DataProvider = CreateDataProvider();
self.scrollView = CreateScrollBoxListLinearView();
self.scrollView:SetDataProvider(self.DataProvider);
---height is defined in the xml keyValues
local height = self.elementHeight;
self.scrollView:SetElementExtent(height);
self.scrollView:SetElementInitializer(self.itemTemplate, GenerateClosure(self.OnElementInitialize, self));
self.scrollView:SetElementResetter(GenerateClosure(self.OnElementReset, self));
self.selectionBehavior = ScrollUtil.AddSelectionBehavior(self.scrollView);
self.scrollView:SetPadding(1, 1, 1, 1, 4);
ScrollUtil.InitScrollBoxListWithScrollBar(self.scrollBox, self.scrollBar, self.scrollView);
local anchorsWithBar = {
CreateAnchor("TOPLEFT", self, "TOPLEFT", 4, -4),
CreateAnchor("BOTTOMRIGHT", self.scrollBar, "BOTTOMLEFT", -4, 4),
};
local anchorsWithoutBar = {
CreateAnchor("TOPLEFT", self, "TOPLEFT", 4, -4),
CreateAnchor("BOTTOMRIGHT", self, "BOTTOMRIGHT", -4, 4),
};
ScrollUtil.AddManagedScrollBarVisibilityBehavior(self.scrollBox, self.scrollBar, anchorsWithBar, anchorsWithoutBar);
end
function ClassicEraCensusListviewMixin:OnElementInitialize(element, elementData, isNew)
if isNew then
--element:OnLoad();
end
local height = self.elementHeight;
element:SetDataBinding(elementData, height);
element:Show()
end
function ClassicEraCensusListviewMixin:OnElementReset(element)
element:ResetDataBinding()
end