Page 1 of 1

Unable to remove gap between two buttons in a flow

Posted: Mon Mar 27, 2023 2:32 pm
by BiterUnion
I am trying to remove the gap between two buttons (more specifically a sprite-button and a button) in a horizontal flow (see attachement). Here is a short snippet that adds a command for creating this GUI:

Code: Select all

commands.add_command('debug_gui', '', function(data)
    local player = game.get_player(data.player_index)
    local frame = player.gui.screen.add {
        type = 'frame'
    }
    frame.force_auto_center()
    local flow = frame.add {
        type = 'flow',
        direction = 'horizontal'
    }
    flow.style.padding = 0
    local button = flow.add {
        type = 'sprite-button',
        style = 'tool_button',
        sprite = 'utility/shuffle'
    }
    button.style.margin = 0
    local list_box_item = flow.add {
        type = 'button',
        style = 'list_box_item',
        caption = 'list box item caption'
    }
    list_box_item.style.margin = 0
end)
I tried setting margins on the buttons to 0 and padding on the flow to 0, but this does not seem to have any effect. Am I misinterpreting how margin and padding works or do you have any other suggestion how to get rid of the gap?

Many thanks in advance!

Re: Unable to remove gap between two buttons in a flow

Posted: Mon Mar 27, 2023 2:59 pm
by InappropriatePenguin
You probably just need to set the horizontal spacing of the flow to 0.

Code: Select all

flow.style.horizontal_spacing = 0

Re: Unable to remove gap between two buttons in a flow

Posted: Mon Mar 27, 2023 3:03 pm
by BiterUnion
That works, many thanks!