Always snap to grid

Legacy:Useful UWindow Extensions/Combobox And Editbox

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Auto-Sizing Combo and Edit controls[edit]

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.