[Bug] Gui.TextAlignment not working?

Started by Pun1sh3r, Dec 25, 2020, 12:50 PM

Previous topic - Next topic

Pun1sh3r

 I tried to create a GUI Text which should be Center but it does nothing? Also tried the rest which is written in the Wiki Page

QuoteFooterText = GUILabel( );
            FooterText.Pos = VectorScreen( sX/7, sY-(sY/28) );
       FooterText.TextAlignment = GUI_ALIGN_CENTER;
            FooterText.FontSize = 20;
            FooterText.TextColour = Colour( 255, 255, 255 );
            FooterText.FontFlags = GUI_FFLAG_BOLD;
            FooterText.Text = FooterString;

QuoteProperty TextAlignment

Type: int

Sets the alignment of text. Available constants are:

GUI_ALIGN_LEFT
GUI_ALIGN_RIGHT
GUI_ALIGN_TOP
GUI_ALIGN_BOTTOM
GUI_ALIGN_CENTERV
GUI_ALIGN_CENTERH
GUI_ALIGN_CENTER

Anything wrong with my Code?

DizzasTeR

Provide a size to the text element. If you are going to use alignment, you have to make sure you "create" a "bounding box" where:

left => Position.X
top => Position.Y
right => Size.X
bottom => Size.Y

Then apply the alignment flags

Pun1sh3r


DizzasTeR

FooterText = GUILabel( );
FooterText.Position = VectorScreen(0, 0); // x is left, y is top
FooterText.Size = VectorScreen(sX, sY); // x is right, y is bottom
FooterText.TextAlignment = GUI_ALIGN_CENTER; // Align it at center
FooterText.FontSize = 20;
FooterText.TextColour = Colour( 255, 255, 255 );
FooterText.FontFlags = GUI_FFLAG_BOLD;
FooterText.Text = FooterString;

(Untested but thats how it should be)

Also its .Position not .Pos