Wikis / Unreal Wiki / Legacy:Useful UWindow Extensions/Combobox And Editbox

Auto-Sizing Combo and Edit controls

These controls consist of a caption and an editbox or a drop-down list. This code changes the width of that box to fill the available space behind the caption without resizing the control itself. Since UWindowEditControl and UWindowComboControl use the same names for the corresponding properties both controls can use the following code:

var bool bAutoSize;
 
function BeforePaint(Canvas C, float X, float Y)
{
    local float TW, TH;
 
    if ( bAutoSize ) {
        TextSize(C, Text, TW, TH);
        EditBoxWidth = WinWidth - TW;
    }
    Super.BeforePaint(C, X, Y);
}

This could also be used for the UWindowHSliderControl (you only need to change EditBoxWidth to SliderWidth), but this only looks good if the slider's text doesn't change when the slider is moved.

Page Information

2022-11-18T15:58:25.673056Z 2002-05-30T19:09:32Z Wormbo also possible with HSlider https://wiki.beyondunreal.com/Legacy:Useful UWindow Extensions/Combobox And Editbox Attribution-NonCommercial-ShareAlike 3.0