Unable to remove gap between two buttons in a flow

Place to get help with not working mods / modding interface.
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

Unable to remove gap between two buttons in a flow

Post 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!
Attachments
screenshot.png
screenshot.png (7.9 KiB) Viewed 804 times
InappropriatePenguin
Inserter
Inserter
Posts: 29
Joined: Mon Sep 13, 2021 6:53 pm
Contact:

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

Post by InappropriatePenguin »

You probably just need to set the horizontal spacing of the flow to 0.

Code: Select all

flow.style.horizontal_spacing = 0
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

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

Post by BiterUnion »

That works, many thanks!
Post Reply

Return to “Modding help”