Thread Tools Display Modes
08-20-22, 05:45 AM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
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?
  Reply With Quote
08-20-22, 06:34 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
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.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
08-20-22, 05:57 PM   #3
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
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)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Drag item inside button and retrieve item info

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