I'm working on organizing my UI layout, but I'm facing a challenge with setting a fixed width for all boxes (widgets). Currently, one workaround I've found is to insert an empty label with a fixed width to force the box to a certain size. However, this approach looks awkward, as it introduces an empty line into the layout.
Is there a better method to enforce a uniform width for all boxes in my UI? Any suggestions or best practices—possibly involving layout managers or style settings—would be greatly appreciated.
Additional details:
There is no easy (or direct) way to control the box width, it will depend on the size of containing elements. The example codes below show how I will handle this situation - using the "DLGInternalPadding()" to adjust the push button size.
class UIExample : UIFrame {
number true, false; // boolean
void DoEnableAction( object self ) OkDialog( "Enable button pushed" );
void DoDisableAction( object self ) OkDialog( "Disable button pushed" );
void ConstructAndDisplayUI( object self ) {
TagGroup tgDialog = DLGCreateDialog( "UIFrame Example");
// create push buttons
number padding_x =30, padding_y =5;
TagGroup tgButton1 = DLGCreatePushButton( "Enable", "DoEnableAction" );
tgButton1.DLGInternalPadding(padding_x, padding_y).DLGFill("XY");
TagGroup tgButton2 = DLGCreatePushButton( "Disable", "DoDisableAction" );
tgButton2.DLGInternalPadding(padding_x, padding_y).DLGFill("XY");
// group push buttons
TagGroup tgGroup = DLGGroupItems( tgButton1, tgButton2 );
tgGroup.DLGTableLayout(2,1, true);
// create a box and add button group as element
TagGroup tgBox = DLGCreateBox( "settings" ).DLGFill("XY");
tgBox.DLGAddElement( tgGroup );
// add box as UI element
tgDialog.DLGAddElement( tgBox );
self.init(tgDialog);
self.Display( "UIFrame example" );
};
UIExample( object self ) { // object constructor
// assign boolean
true = 1;
false = 0;
// object construction verbage;
result( "object \"UIExample\" (" + self.ScriptObjectGetID() + ") constructed\n" );
};
~UIExample( object self ) { // object destructor
// object destruction verbage;
result( "object \"UIExample\" (" + self.ScriptObjectGetID() + ") destructed\n\n" );
};
};
alloc( UIExample ).ConstructAndDisplayUI();