This topic was marked solved by its starter, on December 30th, 2020, 12:34 AM
« [Bugs] Multiple bugs
[Bug] Gui.TextAlignment not working?

Pun1sh3r

  • Wiki Contributor
  • Posts: 30
[Bug] Gui.TextAlignment not working?
«  »
 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
Quote
FooterText = 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;
Quote
Property 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

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,200
[Bug] Re: Gui.TextAlignment not working?
« Reply #1,  »
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

  • Wiki Contributor
  • Posts: 30

DizzasTeR

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,200
[Bug] Re: Gui.TextAlignment not working?
« Reply #3,  »
Code: [Select]
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

« [Bugs] Multiple bugs