Quantcast
Callback when item is clicked in bag - WoWInterface
Thread Tools Display Modes
09-01-19, 04:28 AM   #1
paulinamachtmuh
A Defias Bandit
Join Date: Sep 2019
Posts: 2
Callback when item is clicked in bag

Hello,

can you guys help me. Im trying to create a small addon that will generate macros for me dependant on the weapon that ill be using. For that i want to be able to conveniently select the weapon by clicking on it in my bag. Any hints on what to hook in order to grab the Item Name that I clicked on in my bag?
  Reply With Quote
09-01-19, 01:11 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,924
You can hook ContainerFrameItemButton_OnClick() for normal clicks and ContainerFrameItemButton_OnModifiedClick() for modified ones (Example: Shift-Click). To get the bag and slot numbers from these, you need to do something like this.
Lua Code:
  1. hooksecurefunc("ContainerFrameItemButton_OnClick",function(self,button)
  2.     local bag,slot=self:GetParent():GetID(),self:GetID();
  3. --  Do stuff here
  4. end);


Note: Both left and right mouse buttons are already in use by the game. Left lets you move the item while right will equip the weapon you want to click. If you register extra buttons to be recognized as clicks, these functions will pick up the extra buttons as right-clicks. There are better ways of detecting a weapon swap if that's your goal instead. Also keep in mind, macros cannot be edited while in combat, though weapon swapping cannot happen during combat either.

Another option is to use the [equipped] macro conditional. See Macro Conditionals.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 09-01-19 at 01:22 PM.
  Reply With Quote
09-01-19, 03:07 PM   #3
paulinamachtmuh
A Defias Bandit
Join Date: Sep 2019
Posts: 2
thank you very much, working perfectly fine. One more question. Do you know a way to actually display the icon of the item within my gui? I couldnt find any predefined element that would let me do it.
  Reply With Quote
09-02-19, 07:42 AM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,924
You can grab the icon from GetContainerItemInfo() and just create a texture object to display it. If you really want to be fancy, you could create a button using the ItemButtonTemplate or ActionButtonTemplate. Whichever suits your needs.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Callback when item is clicked in bag

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