Addon Button to use an Item - Resolved

So I just got into learning how to make addons as of yesterday, you know the day where I’m pretty changed a lot as a bunch of things broke on other addons.

Well as I’m learning I was trying to make a simple addon that adds a button that when I click on it, it will use Sea Scorpion (also other items once I get the basic stuff working).

I have the button showing up, it can be clicked, it’ll run a SetScript thing, but from what I can tell the way you make it actually use the item in your bag is via the following:

button:SetAttribute("type", "item")
button:SetAttribute("item", "Sea Scorpion") 

However when I have that in my code, and click on the button, nothing more happens (no errors as well).
So I am just confused what I need to be doing, or if things are just broken due to Tuesday, or if I am just completely missing something.
Also if you want to help, but aren’t sure if I am missing something or not, just assume I am missing it.
(Also thank you, and hopefully this is an alright place to ask)

Also almost forgot to mention this in retail

All the code for the button would help but a quick guess would be that you didn’t RegisterForClicks

button:RegisterForClicks("AnyUp")

or possibly

button:RegisterForClicks("AnyDown", "AnyUp")
1 Like

Many thanks that worked! I didn’t realize that was a thing, but makes sense now when I consider the SetScript specifics “OnClick” so it makes sense I’d have to add functionality to a button I am making.

Thank you! Now onto some more coding fun.