Thread Tools Display Modes
05/29/18, 10:29 PM   #1
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
[Solved] Text Formatting in text control?

I have a lua made control:

Code:
page = WINDOW_MANAGER:CreateControlFromVirtual("someparent", someplace, "ZO_DefaultEditMultiLineForBackdrop")
...
It works fine. However, when text is displayed it ignores |cFFFFFFtext|r and other tags. I've searched the code, xmls, articles, forums, and couldn't figure out how to either toggle that display mode, so it can show colored text using the game tags, or change it into another template that works the same but displays colors.

To clarify, I have no issue setting the text color for the control. I want "|cFF0000TEXT|r" to show "TEXT" with the color. Just like in other text controls in the game.

Any clues?

Last edited by Phuein : 05/30/18 at 02:23 PM.
  Reply With Quote
05/29/18, 10:47 PM   #2
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 312
only valid control function are here:
http://wiki.esoui.com/Controls#EditControl

because your reference is an edit control:
ZO_DefaultEditMultiLineForBackdrop

as far i see, ZOS running like this:
xml Code:
  1. <Backdrop name="$(parent)DescriptionBody" inherits="ZO_MultiLineEditBackdrop_Keyboard">
  2.      <Dimensions x="550" y="150"/>
  3.      <Anchor point="TOPLEFT" relativeTo="$(parent)DescriptionTitle" relativePoint="BOTTOMLEFT" offsetY="10" />
  4.           <EditBox name="$(parent)Field" inherits="ZO_DefaultEditMultiLineForBackdrop ZO_EditDefaultText"/>
  5.      </Controls>
  6. </Backdrop>

in the inherit there is ZO_EditDefaultText: DescriptionBodyFieldText:SetColor(1,1,1,1)

maybe this works for the lua too:
page = WINDOW_MANAGER:CreateControlFromVirtual("someparent", someplace, "ZO_DefaultEditMultiLineForBackdrop ZO_EditDefaultText")
pageText:SetColor(1,1,1,1) ?
  Reply With Quote
05/29/18, 10:56 PM   #3
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by Scootworks View Post
only valid control function are here:
http://wiki.esoui.com/Controls#EditControl

because your reference is an edit control:
ZO_DefaultEditMultiLineForBackdrop

as far i see, ZOS running like this:
xml Code:
  1. <Backdrop name="$(parent)DescriptionBody" inherits="ZO_MultiLineEditBackdrop_Keyboard">
  2.      <Dimensions x="550" y="150"/>
  3.      <Anchor point="TOPLEFT" relativeTo="$(parent)DescriptionTitle" relativePoint="BOTTOMLEFT" offsetY="10" />
  4.           <EditBox name="$(parent)Field" inherits="ZO_DefaultEditMultiLineForBackdrop ZO_EditDefaultText"/>
  5.      </Controls>
  6. </Backdrop>

in the inherit there is ZO_EditDefaultText: DescriptionBodyFieldText:SetColor(1,1,1,1)

maybe this works for the lua too:
page = WINDOW_MANAGER:CreateControlFromVirtual("someparent", someplace, "ZO_DefaultEditMultiLineForBackdrop ZO_EditDefaultText")
pageText:SetColor(1,1,1,1) ?

To clarify, I have no issue setting the text color for the control. I want "|cFF0000TEXT|r" to show "TEXT" with the color. Just like in other text controls in the game.

Last edited by Phuein : 05/29/18 at 11:13 PM.
  Reply With Quote
05/30/18, 05:19 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,567
Originally Posted by Phuein View Post
To clarify, I have no issue setting the text color for the control. I want "|cFF0000TEXT|r" to show "TEXT" with the color. Just like in other text controls in the game.
Every control has different functionality. The text input control does not support what you are trying to do. You'd have to use a label control.
  Reply With Quote
05/30/18, 12:23 PM   #5
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by sirinsidiator View Post
Every control has different functionality. The text input control does not support what you are trying to do. You'd have to use a label control.

Hrm. I saw that the game in the guild window in MOTD uses a ZO_SavingEditBox():
http://esodata.uesp.net/current/src/...rd.lua.html#25

I wanted to replicate that behavior, but trying different templates, none of them did. So, you're saying the game replaces the editbox with a label for this need? I don't see it in the code.
  Reply With Quote
05/30/18, 12:52 PM   #6
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,567
The ZO_ScrollingSavingEditBox is a highly complex object that combines several controls and uses lua code to achieve the behavior you see with the MotD. You cannot replicate it just by letting an edit box control inherit its template. Instead you'd have to use it as seen in the code for the guild MotD.

I'd also recommend you look at the source code extract on github, since UESP doesn't seem to include the xml files.
  Reply With Quote
05/30/18, 02:24 PM   #7
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by sirinsidiator View Post
The ZO_ScrollingSavingEditBox is a highly complex object that combines several controls and uses lua code to achieve the behavior you see with the MotD. You cannot replicate it just by letting an edit box control inherit its template. Instead you'd have to use it as seen in the code for the guild MotD.

I'd also recommend you look at the source code extract on github, since UESP doesn't seem to include the xml files.

Your advice to check the .xml on github really helped. I saw that it is the case they just use 2 controls, one for edit and one for display, and switch them. I did just that, and now it works as expected. Just toggle SetHidden and TakeFocus OnMouseUp if upInside and reverse OnFocusLost.

Thanks for helping! Saved me on this one.
  Reply With Quote
05/30/18, 04:19 PM   #8
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 551
In the next major version edit boxes will have the XML attribute "escapeMarkup" which you can set to false to achieve this.
  Reply With Quote
05/31/18, 02:56 PM   #9
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by ZOS_ChipHilseberg View Post
In the next major version edit boxes will have the XML attribute "escapeMarkup" which you can set to false to achieve this.

Exactly what I was wondering. Toggles make life easy. Thanks dev.
  Reply With Quote
08/16/18, 12:06 PM   #10
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by ZOS_ChipHilseberg View Post
In the next major version edit boxes will have the XML attribute "escapeMarkup" which you can set to false to achieve this.
Following the tradition of GetEditEnabled() and SetEditEnabled(), could we get a GetEscapeMarkup() to make verification of the state easier?
EDIT: Just ran into ShouldEscapeMarkup() which does just that, but goes off tradition. :P Funny.

Also, testing this new function, it doesn't update the display immediately. The old solution that toggles hiding between an Editbox and Label works immediately, which means they're not interchangeable yet.

Thanks for the great work!

Last edited by Phuein : 08/16/18 at 12:12 PM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Control to display colors in text?

Thread Tools
Display Modes

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