Thread Tools Display Modes
05/19/16, 01:54 PM   #1
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Aligning input text inside <Editbox>

Hey, does anybody know how to align text inside an edit control? The shared verticalAlignment attribute does not work, editbox:SetVerticalAlignment doesn't work either (although it does not throw an error!). This really drives me crazy, there must be an elegant way without using dimension constraints for the editbox itself.
As always: I don't want to inherit from an original zenimax editbox because I want a custom style.

Cheers
  Reply With Quote
05/20/16, 03:35 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,971
Yo uneed to use these values for the :SetVerticalAlignment(value) and :SetHorizontalAlignment(value) functions, if I remember correctly:

Code:
TEXT_ALIGN_BOTTOM
TEXT_ALIGN_CENTER
TEXT_ALIGN_LEFT
TEXT_ALIGN_RIGHT
TEXT_ALIGN_TOP
  Reply With Quote
05/20/16, 07:20 AM   #3
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
I've tried that, doesnt work
<Editbox> does not have any child-nodes for alignment.
  Reply With Quote
05/20/16, 07:30 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
If you only need one line you may be able to fake it.
Just center the editbox and grow it as more characters are added (OnTextChanged).
You can get the necessary width with the help of a hidden label and GetTextWidth.
In order to make clicking the textbox work like usual, just add a click handler to the background and let it give focus to the editbox via the TakeFocus method.
  Reply With Quote
05/20/16, 08:23 AM   #5
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Originally Posted by sirinsidiator View Post
If you only need one line you may be able to fake it.
Just center the editbox and grow it as more characters are added (OnTextChanged).
You can get the necessary width with the help of a hidden label and GetTextWidth.
In order to make clicking the textbox work like usual, just add a click handler to the background and let it give focus to the editbox via the TakeFocus method.
The problem with fake editboxes is, that the user input text does not grow into both directions, that's what a centered text should do

Didn't know backdrops accept click handler functionality? :O
  Reply With Quote
05/20/16, 08:39 AM   #6
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
It does if the editbox width is equal to the text width and you anchor it centered. Every time when the text changes you update the width of the editbox and the game will take care of the rest.
You are right, backdrops do not offer a click handler, but you could simply make an empty control that is a child of the backdrop and fills it completely.
  Reply With Quote
05/20/16, 10:31 AM   #7
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Worked, perfectly thank you very much!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Aligning input text inside <Editbox>


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