Quantcast Is it not possible to get a mail attachment name? - ESOUI
Thread Tools Display Modes
04/27/19, 11:30 AM   #1
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 60
Is it not possible to get a mail attachment's name?

tl;dr My goal is to click an inbox attachment and print its name into the chat input box, for quick copying. (Not into the chat output.)

When clicking an inventory item, I can pre-hook into the event and get its data.name. But with inbox mail attachments, they don't have a bagId], so it's not possible to get that data the same way.

I've tried inspecting MAIL_INBOX thoroughly. Same for the attachmentslot in the event and its parents.

I've looked through the forums.

Two days now, and when I realized I could check the one event exposed on right-clicking attachments Link in Chat, I saw it uses an unexposed function ZO_LinkHandler_CreateChatLink. Dead end.

EDIT: Even just tried hooking into link creation, to grab the text output on the way, but it wouldn't let me.

Any clues? Just not possible without overhauling the whole thing? Should the devs just expose the name in the control?


https://esoapi.uesp.net/100026/src/i...board.lua.html

https://esoapi.uesp.net/100026/src/i...yslot.lua.html
__________________
Author of beloved and rejuvenated addons:
ShowMount             PvP FPS 2018
Notebook 2018         Junkee 2018
BestFriends 2018       New Addon

Last edited by Phuein : 04/27/19 at 11:51 AM.
  Reply With Quote
04/27/19, 12:21 PM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,220
Not sure what you mean with ZO_LinkHandler_CreateChatLink is "unexposed"? It is a global function defined in zo_linkhandler.lua, but you won't need it for getting the attachment name, since all it basically does is call the function that is passed to it.

Reading mailinbox_keyboard.lua you can see how the attachment slots are created. The important part is where ZO_Inventory_BindSlot is called with SLOT_TYPE_MAIL_ATTACHMENT. This determines what happens when you interact with that item slot. When you search the inventoryslot.lua for that slot type, you can see that it passes GetAttachedItemLink, MAIL_INBOX:GetOpenMailId() and ZO_Inventory_GetSlotIndex(inventorySlot) to ZO_LinkHandler_CreateChatLink.

This means calling GetAttachedItemLink(MAIL_INBOX:GetOpenMailId(), ZO_Inventory_GetSlotIndex(inventorySlot)) will give you the item link for the attachment and from there you can use any of the item link functions to extract whatever info you need.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
I finally got a Patreon page!
  Reply With Quote
04/27/19, 01:37 PM   #3
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 60
Thumbs up

Originally Posted by sirinsidiator View Post
Not sure what you mean with ZO_LinkHandler_CreateChatLink is "unexposed"? It is a global function defined in zo_linkhandler.lua, but you won't need it for getting the attachment name, since all it basically does is call the function that is passed to it.

Reading mailinbox_keyboard.lua you can see how the attachment slots are created. The important part is where ZO_Inventory_BindSlot is called with SLOT_TYPE_MAIL_ATTACHMENT. This determines what happens when you interact with that item slot. When you search the inventoryslot.lua for that slot type, you can see that it passes GetAttachedItemLink, MAIL_INBOX:GetOpenMailId() and ZO_Inventory_GetSlotIndex(inventorySlot) to ZO_LinkHandler_CreateChatLink.

This means calling GetAttachedItemLink(MAIL_INBOX:GetOpenMailId(), ZO_Inventory_GetSlotIndex(inventorySlot)) will give you the item link for the attachment and from there you can use any of the item link functions to extract whatever info you need.

(If you follow that definition, you get linkFunction() which again is meaningless. Doesn't tell me how to get the name without a bagId.)

I was going to say that I had already tracked into SLOT_TYPE_MAIL_ATTACHMENT, when I clicked GetAttachedItemLink again, and again seeing no definition - but this time clicking on the single reference mentioned there. Ironically, a line below that reference has GetItemLinkName() which gives me a solution.

A convoluted and awkward solution, but it does work! Thanks again siri.

tl;dr
Code:
local link = GetAttachedItemLink(MAIL_INBOX:GetOpenMailId(), ZO_Inventory_GetSlotIndex(inventorySlot), LINK_STYLE_DEFAULT)
local name = GetItemLinkName(link)

ESO DEVELOPERS: Would be nice if the Control just had this .name in a .data, like the inventory does. How come it doesn't?
__________________
Author of beloved and rejuvenated addons:
ShowMount             PvP FPS 2018
Notebook 2018         Junkee 2018
BestFriends 2018       New Addon

Last edited by Phuein : 04/27/19 at 02:01 PM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Is it not possible to get a mail attachment name?

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