API Change in 10.0 ContainerFrameItemButton OnModifiedClick

hooksecurefunc("ContainerFrameItemButton_OnModifiedClick, Function Name) is bad
Anyone know what I should be doing here instead?

2 Likes

running into the same problem… you didn’t happen to solve it did you?

Is it related to these shenanigans?

Also, looks like you’re missing closing quotes in the example you posted.
Make sure to wrap your code in code tags ``` code ``` (or </> in the editor), so the forums don’t mess up your code.

ContainerFrameItemButton_OnModifiedClick no longer exists in 10.0. They moved that to a mixin:

function ContainerFrameItemButtonMixin:OnModifiedClick(button)
	local itemLocation = ItemLocation:CreateFromBagAndSlot(self:GetBagID(), self:GetID());
	if ( IsModifiedClick("EXPANDITEM") ) then
		if C_Item.DoesItemExist(itemLocation) then
			if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(itemLocation) and C_Item.CanViewItemPowers(itemLocation) then
				OpenAzeriteEmpoweredItemUIFromItemLocation(itemLocation);
				return;
			end

			local heartItemLocation = C_AzeriteItem.FindActiveAzeriteItem();
			if heartItemLocation and heartItemLocation:IsEqualTo(itemLocation) then
				OpenAzeriteEssenceUIFromItemLocation(itemLocation);
				return;
			end

			if SocketContainerItem(self:GetBagID(), self:GetID()) then
				return;
			end
		end
	end

	if ( HandleModifiedItemClick(GetContainerItemLink(self:GetBagID(), self:GetID()), itemLocation) ) then
		return;
	end
	if ( not CursorHasItem() and IsModifiedClick("SPLITSTACK") ) then
		local texture, itemCount, locked = GetContainerItemInfo(self:GetBagID(), self:GetID());
		if ( not locked and itemCount and itemCount > 1) then
			self.SplitStack = SplitStack;
			StackSplitFrame:OpenStackSplitFrame(itemCount, self, "BOTTOMRIGHT", "TOPRIGHT");
		end
	end
end

A mixin “mixes” code into other stuff. In this case each button has a reference to the above code.

This is a brute force hook of the first 20 slots of the first opened bag (likely backpack if all separate bags opened)

for i=1,20 do
  local button = _G["ContainerFrame1Item"..i]
  if button then
    hooksecurefunc(button,"OnModifiedClick",function(self,...)
      print("OnModifiedClick",...)
    end)
  end
end
1 Like

Yes I solved.

hooksecurefunc(“HandleModifiedItemClick”, function(itemLink, itemLocation)
local button = GetMouseButtonClicked()
–My if logic here
– such as
–if (button == “RightButton” and IsAltKeyDown() and IsControlKeyDown()) then
– do something
– end
)

However I didn’t need location, just itemLink, so I have no idea if itemLocation works or what it returns sorry. Someone helped me in WoWUIDev discord, but the itemLocation was sending nil I think, but I dont’ need now. Before I think i needed bag/slot # to get itemlink, but now itemlink is sent.

The HandleModifiedItemClick handles any item clicked, anywhere. Your player equipment, encounter journal, etc. If needed, you can check the itemLocation to see if it originated from your bags.

hooksecurefunc("HandleModifiedItemClick", function(link, itemLocation)
    if itemLocation and itemLocation:IsBagAndSlot() then
        -- if you need item information you can parse it from the link or use
        -- Item:CreateFromItemLocation(itemLocation)

        -- if you need the frame, as long as your bags are open you can use
        -- ContainerFrameUtil_GetItemButtonAndContainer(itemLocation:GetBagAndSlot())
    end
end)

I wanted to ask for your help because you helped me out last time and this question seems to be well inside your area of expertise. I’m ready for some more advanced stuff.
I wanted to start easy by changing out the player / target flash frames with my own texture but have them behave the same way with the default.

I know it starts with getting back into console. I did it once have to remember how I did that again.
2. putting in the command for the code to extract the blp and code files I forgot what the command is.
3. convert the blp to a tga.
4. add in the texture in blip or photoshop.
5. Swap it out with your own choice of texture.

At this point I’m a little confused. Would I create a new folder with the original Lua / toc for the flash frame as an add-on? Or just replace the file in the blp with the new texture.
But if I did that it wouldn’t be in the right area and would need to be moved first into the right place with the Lua. :smirk:

I’m starting to understand this pretty well as far what I need to do. I just need a little help along the way. :grin: