uiaccordeonbutton.lua

main 26 lines · 610 bytes Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1-- @docclass
2UIAccordeonButton = extends(UIButton, "UIAccordeonButton")
3
4function UIAccordeonButton.create()
5 local btn = UIAccordeonButton.internalCreate()
6 btn:setOn(false)
7 return btn
8end
9
10function UIAccordeonButton.onClick(self)
11 local contentPanel = self:getParent():getChildAfter(self)
12
13 if not contentPanel or #contentPanel:getChildren() == 0 then -- disable if there is no content to show
14 return
15 end
16
17 if not self:isOn() then
18 contentPanel:getLayout():setFitChildren(true)
19 else
20 contentPanel:getLayout():setFitChildren(false)
21 contentPanel:setHeight(0)
22 end
23
24 self:setOn(not self:isOn())
25end
26
Top