Four Js Development Tools Forum

General => Ask Reuben => Topic started by: Reuben B. on March 30, 2021, 04:57:21 am

Title: Ask Reuben 68 - Spacer vs Space
Post by: Reuben B. on March 30, 2021, 04:57:21 am
This question came from a developer who was trying to use a spacer to force a gap between two adjacent widgets.

For those who have not come across a spacer before, it is something you can use with HBox-tags and is an invisible element that automatically expands. It can be used to align elements left, right or center in the hbox.

So despite the name, a spacer does not necessarily add a space, its purpose is alignment.   I like to think of it as a spring that is forcing apart adjacent widgets so that they align without being resized.  That spring can be compressed so that it does not take up any space and that is where the confusion may arise.

If you want to force a space between adjacent fields, then you need to do something to ensure that the width of the grid columns between the two fields is greater than zero.  That can be achieved by adding a LABEL between the two adjacent widgets that has a non-empty TEXT attribute, the simplest case being a single space.  This has the desired effect of making the grid column between the adjacent widgets have the minimum width necessary to display a space in the current font.