Page 1 of 1

Style.margin/padding doesn't work correctly on switches

Posted: Sat Aug 15, 2020 11:14 am
by Therenas
At least, I think it doesn't. When setting margin/padding on switches, it applies it to the switch button itself, and not the whole element, including its labels. The following code demonstrates this (change margin for padding to see both things):

Code: Select all

local frame = player.gui.screen.add{type="frame"}
frame.force_auto_center()
local switch = frame.add{type="switch", switch_state="left", left_label_caption="ON", right_label_caption="OFF"}
switch.style.left_margin = 30
When setting a margin, it looks like this, when setting padding, like this. What I think it should do with margin is shift the whole element to the right, including labels, instead of move the button away from its label. For padding, I'm not 100% sure what it should do, but what it does currently is not super useful I think. I'm open to being wrong about this ofc, there might be a reason for why it is like this.