uiaccordeonlistitem.lua

main 40 lines · 1 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1-- @docclass
2UIAccordeonListItem = extends(UIWidget, "UIAccordeonListItem")
3
4function UIAccordeonListItem.create()
5 local panel = UIAccordeonListItem.internalCreate()
6 return panel
7end
8
9function UIAccordeonListItem:onStyleApply(styleName, styleNode)
10 for name,value in pairs(styleNode) do
11 if name == 'title' then
12 self.title = value -- delayed execution
13 end
14 end
15end
16
17function UIAccordeonListItem:onLayoutUpdate()
18 local title = self:recursiveGetChildById('title')
19 if title and self.title ~= nil then
20 title:setText(self.title)
21 self.title = nil
22 end
23
24 -- couldn't find a better way to do this, but basically move all the added children to content panel automatically
25 for i=#self:getChildren(), 3, -1 do
26 self:recursiveGetChildById('content'):addChild(self:getChildren()[i])
27 end
28end
29
30function UIAccordeonListItem:setTitle(text)
31 local title = self:recursiveGetChildById('title')
32 if title then
33 title:setText(text)
34 end
35end
36
37function UIAccordeonListItem:clearChildren()
38 self:getChildById("content"):clearChildren()
39end
40
Top