Thread Tools Display Modes
09/13/21, 05:34 PM   #1
dorrino
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 50
ZO_LinkHandler_CreateLinkWithFormat and zo_iconformat

I'm trying to attach a character link an icon in a text string. So on rightclicking the icon i'll get a specific character context menu.

And the problem is that if i feed zo_iconformat to ZO_LinkHandler_CreateLinkWithFormat then the icon is not parsed but instead is treated as a string of characters.

Does anybody know of a workaround?



Essentially ZO_LinkHandler_CreateLinkWithFormat produces a string like:

"|HLINK_STYLE_DEFAULT:character:Charname^Mx|hTEXT|h"

and i feed zo_iconformat instead of TEXT, so the result looks like:

"|HLINK_STYLE_DEFAULT:character:Charname^Mx|h|t64:64:mypath\myicon.dds|t|h"

And |t64:64:mypath\myicon.dds|t is treated as a literal string of symbols instead of the icon.
  Reply With Quote
09/14/21, 03:12 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,568
The game does not support nested markup. However, there is a really wonky way to do what you want.
Simply put you can abuse how the link markup behaves to span over the icon.
That's how I managed to create the clickable icon in Chat2Clipboard:
Lua Code:
  1. local ICON_SIZE = 12
  2. local COPY_LINK_TYPE = "copyText"
  3. local COPY_LINK_ICON = zo_iconFormat("Chat2Clipboard/images/copy.dds", ICON_SIZE, ICON_SIZE)
  4. local REVERSE_BLANK_ICON = zo_iconFormat("blank.dds", -7, ICON_SIZE)
  5. -- we use a negative image width to go outside the visible area, then place a link with a dot and space as text and then the actual icon
  6. -- the combination of char - space spans the link through the image until the next char appears in the string
  7. local COPY_LINK_FORMAT = ("%s|Hignore:%s:%%d:%%d|h. |h%s"):format(REVERSE_BLANK_ICON, COPY_LINK_TYPE, COPY_LINK_ICON)
  Reply With Quote
09/14/21, 02:44 PM   #3
dorrino
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 50
Originally Posted by sirinsidiator View Post
The game does not support nested markup. However, there is a really wonky way to do what you want.
Simply put you can abuse how the link markup behaves to span over the icon.
That's how I managed to create the clickable icon in Chat2Clipboard:
Lua Code:
  1. local ICON_SIZE = 12
  2. local COPY_LINK_TYPE = "copyText"
  3. local COPY_LINK_ICON = zo_iconFormat("Chat2Clipboard/images/copy.dds", ICON_SIZE, ICON_SIZE)
  4. local REVERSE_BLANK_ICON = zo_iconFormat("blank.dds", -7, ICON_SIZE)
  5. -- we use a negative image width to go outside the visible area, then place a link with a dot and space as text and then the actual icon
  6. -- the combination of char - space spans the link through the image until the next char appears in the string
  7. local COPY_LINK_FORMAT = ("%s|Hignore:%s:%%d:%%d|h. |h%s"):format(REVERSE_BLANK_ICON, COPY_LINK_TYPE, COPY_LINK_ICON)
This worked perfectly!

Hugely appreciated.

I totally suspected there should be a hacky workaround!

Much love!
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » ZO_LinkHandler_CreateLinkWithFormat and zo_iconformat

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