ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Control to display colors in text? (https://www.esoui.com/forums/showthread.php?t=7817)

Phuein 05/29/18 10:29 PM

[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?

Scootworks 05/29/18 10:47 PM

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) ?

Phuein 05/29/18 10:56 PM

Quote:

Originally Posted by Scootworks (Post 34832)
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.

sirinsidiator 05/30/18 05:19 AM

Quote:

Originally Posted by Phuein (Post 34833)
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.

Phuein 05/30/18 12:23 PM

Quote:

Originally Posted by sirinsidiator (Post 34839)
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.

sirinsidiator 05/30/18 12:52 PM

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.

Phuein 05/30/18 02:24 PM

Quote:

Originally Posted by sirinsidiator (Post 34855)
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.

ZOS_ChipHilseberg 05/30/18 04:19 PM

In the next major version edit boxes will have the XML attribute "escapeMarkup" which you can set to false to achieve this.

Phuein 05/31/18 02:56 PM

Quote:

Originally Posted by ZOS_ChipHilseberg (Post 34859)
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. :D Toggles make life easy. Thanks dev.

Phuein 08/16/18 12:06 PM

Quote:

Originally Posted by ZOS_ChipHilseberg (Post 34859)
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!


All times are GMT -6. The time now is 01:17 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI