Thread Tools Display Modes
09/20/14, 03:01 PM   #1
w33zl
 
w33zl's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 13
Problem right-aligning text

Hi, I seem to have a problem right-aligning text. Has anybody else experienced something similar? I really can't figure out what I've missed (probably some stupid minor detail I gues ). See example below (simplified):

Code:
<Label name="MyLabel" width="100" horizontalAlignment="RIGHT" text="My text" ... >

The text gets rendered but always left-aligned (even if I also run the code below).

Code:
MyLabel::SetHorizontalAlignment(RIGHT)
  Reply With Quote
09/20/14, 05:21 PM   #2
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
Try TEXT_ALIGN_RIGHT
  Reply With Quote
09/20/14, 05:43 PM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Sasky View Post
Try TEXT_ALIGN_RIGHT
In XML should be "RIGHT":
XML Code:
  1. <Label name="MyLabel" horizontalAlignment="RIGHT" />

In Lua should be TEXT_ALIGN_RIGHT:
Lua Code:
  1. MyLabel:SetHorizontalAlignment(TEXT_ALIGN_RIGHT)
  Reply With Quote
09/21/14, 02:02 AM   #4
w33zl
 
w33zl's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 13
Originally Posted by Garkin View Post
In XML should be "RIGHT":
XML Code:
  1. <Label name="MyLabel" horizontalAlignment="RIGHT" />

In Lua should be TEXT_ALIGN_RIGHT:
Lua Code:
  1. MyLabel:SetHorizontalAlignment(TEXT_ALIGN_RIGHT)
I tried both alternatives without success. However, it seems I might have even bigger problems. On another label I tried setting the wrapMode="ELLIPSIS" which doesn't work either. Could these two problems be correlated?

Trying to further debug this issue I set a backdrop with 1 unit wide border and now I see the label is exactly the width of the text, regardless of what is set in the width attribute. It seems like it auto-sizes, but I could not find any "auto size" attribute on the wiki. Any thoughts here? Might be worth mentioning I'm creating these controls from a template using CreateControlFromVirtual.
  Reply With Quote
09/21/14, 04:43 AM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by w33zl View Post
I tried both alternatives without success. However, it seems I might have even bigger problems. On another label I tried setting the wrapMode="ELLIPSIS" which doesn't work either. Could these two problems be correlated?

Trying to further debug this issue I set a backdrop with 1 unit wide border and now I see the label is exactly the width of the text, regardless of what is set in the width attribute. It seems like it auto-sizes, but I could not find any "auto size" attribute on the wiki. Any thoughts here? Might be worth mentioning I'm creating these controls from a template using CreateControlFromVirtual.
Label does not have attribute "width" (as you have in your example), in XML you have to use <Dimensions x="???" y="???" />:
XML Code:
  1. <Label name="MyLabel" horizontalAlignment="RIGHT" text="My text" warpMode="ELLIPSIS">
  2.     <Dimensions x="100" />
  3. </Label>

In Lua you can set width directly:
Lua Code:
  1. MyLabel:SetWidth(100)

If you are creating labels from the template, your label will inherit all defined attributes. Make sure that template does not define dimension constraints and it doesn't resize to fit descendents, padding and whatever. The safest way is creating your own templates.
  Reply With Quote
09/21/14, 06:43 AM   #6
w33zl
 
w33zl's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 13
Originally Posted by Garkin View Post
Label does not have attribute "width" (as you have in your example), in XML you have to use <Dimensions x="???" y="???" />
Great! I was pretty sure I'd missed some tiny detail . This solved the issue. Thanks!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Problem right-aligning text


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off