WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Drag item inside button and retrieve item info (https://www.wowinterface.com/forums/showthread.php?t=59196)

Benalish 08-20-22 05:45 AM

Drag item inside button and retrieve item info
 
I created a button. Once I have dragged an item (for example, an object from the bags) into the button, how can I retrieve information about the item such as, for example, its icon?

Xrystal 08-20-22 06:34 AM

This might point you in the right direction.
https://wowpedia.fandom.com/wiki/UIH..._OnReceiveDrag

I haven't done anything like this before myself but this page sounds like it covers the task you are trying.

Gello 08-20-22 05:57 PM

GetCursorInfo() says what's on the cursor. You can call that when your button receives something:
Lua Code:
  1. local f = CreateFrame("ItemButton","RdD",UIParent)
  2. f:SetPoint("CENTER",-200,0)
  3.  
  4. local function onReceive(self)
  5.   local cursorType, cursorID, cursorLink = GetCursorInfo()
  6.   if cursorType=="item" then
  7.     local _,_,_,_,icon = GetItemInfoInstant(cursorID)
  8.     self.icon:SetTexture(icon)
  9.     ClearCursor()
  10.   end
  11. end
  12.  
  13. f:SetScript("OnReceiveDrag",onReceive)
  14. f:SetScript("OnClick",onReceive)


All times are GMT -6. The time now is 11:49 PM.

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