ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Is it not possible to get a mail attachment name? (https://www.esoui.com/forums/showthread.php?t=8491)

Phuein 04/27/19 11:30 AM

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

sirinsidiator 04/27/19 12:21 PM

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.

Phuein 04/27/19 01:37 PM

Quote:

Originally Posted by sirinsidiator (Post 37905)
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. :banana: How come it doesn't?


All times are GMT -6. The time now is 10:50 AM.

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