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

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

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

Post 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.

Post Reply

Return to “Modding interface requests”