Quantcast WoWInterface - View Single Post - Callback when item is clicked in bag
View Single Post
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,918
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