On Right Click get ItemId (Classsic SoD)
First time poster... I am in the very beginning stages of writing my first AddOn and its not going well. For this reason I am trying to just print messages for debugging and I am stuck with registering when right click happens, while left shift key is down, and the bank is open. Individually all 3 of these are satisfied through testing but my print message is not received let alone the rest of the function...
Ultimately I would like to retrieve the items information that was just right clicked. I know this is probably simple but I have searched all over and most of the help must be outdated or not compatible with Classic as any of the events I come across have zero documentation. Code:
-- Create the frame |
Somethng to start with.
Place a button that looks like the keyring button in the TOPLEFT of the screen: Lua Code:
This won't do anything with information about bank items as they are their own separate buttons and it depends on what information you want and what you want to do with it as the buttons are already placing the items on the cursor or opening the stack count selector. |
Thank you for the reply! So are you saying that you cannot override or tag along a Blizzard function? Such that I intercept the stack count option and instead execute something else? It appears I can only register clicks on my own widgets?
Also it is worth mentioning that I don't want to do anything with the items in the bank. I actually want to interact with items in my inventory but only if the bank is open. |
Maybe this as a starting point to print the item hyperlink if the bank is open and left shift key is down (doesn't discrimiate the container the clicked item is in but you should be able to determine that using self:GetParent():GetID() as that should be the parent bag/bank slot id.):
Lua Code:
This primarily hooks the functions called by the Blizzard item slots depending on modified state (so maybe you only need one?) |
Wow, that is much tighter than the path I was going down. My biggest struggle is knowing the library available and syntax. How would I have know ContainerFrameItemButton_OnClick or ContainerFrameItemButton_OnModifiedClick was a thing? If I even google just that I get quite literally about zero results. I have browsed all over wowpedia which can be helpful but has not been for anything within this post.
Could you also please break down (C_Container.GetContainerItemInfo(self:GetParent():GetID(), self:GetID()).hyperlink)? It looks as though that requires container index and slot index which I don't quite see how those values are passed into this. Thank you again for the help! |
Essentially each item slot button has an id which is it's position in the container so that's self:GetID() The parent of the slot is the container (bag/bank slot) and it also has an id so that's self:GetParent():GetID()
C_Container.GetContainerItemInfo uses those to return a table of information about what's in a given slot in a given container. The hooked functions was from looking at the code for the item slot button (which is a standard torturous trail you can start with /fstack find the button name on down through multiple inherited templates). Which all starts with exporting the code for the game UI and a good search tool or possibly Gethe's on-line export. warcraft.wiki.gg is the new home of API documentation. wowpedia will get more and more stale as time goes by |
You've been a huge help! I have peaked into all of those resources and will be using them religiously. I was disappointed to see having the bank open appears to change things up, as C_Container.UseContainerItem now places items in the bank (otherwise is blocked), and there doesn't appear to be a way to use an item in any way shape or form via lua? That's probably obvious to veterans.
I noticed UseItemByName, UseContainerItem, RunMacro, RunMacroText are all protected which I assume cannot be called? |
The hooks just run after the original called function is actioned so they don't change hoe clicking an item fundamentally works. That would take a much more complicated approach which would change the bags/bank workings entirely.
The protected function can only be used in response to a hardware event (keyboard/mouse click) usually on a widget that derives from a secure template I think this thread might be useful, at least in terms of the idea of how it works using a SecureActionButtonTemplate in conjunction with macro text. |
Sorry my previous post was probably a bit confusing. What I meant was your script worked great and I understand it. Completely separate from it I was discouraged to see that the blizzard API seems to work differently when at a bank in general, as C_Container.UseContainerItem is blocked unless you are at a bank even though it does not say it's protected. This must be because right clicking items at a bank or "using them" just deposits them rather than casts the item spell.
I had tried every way I could find to provoke using an item while at the bank which included RunMacro although that was just an effort to see if anything would work. The entire idea behind this was I wanted to create an addon that when you hold down shift and right click items while the bank window is open it would use the item rather than deposit it. The most practical example personally is enchanting dust going from Lesser to Greater and needing to close the bank, consolidate, then re-deposit. I know this is completely silly but I thought it would be a very easy first addon project for myself to learn from. Based on your last reply this would be much much more complex to do? |
Quote:
|
All times are GMT -6. The time now is 01:49 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI