1. #1

    How to get the clicked item info in profession window?

    Hi,

    How do you get the clicked item info using the UPDATE_TRADESKILL_RECAST event which is fired when you click on an item in the Profession window?

    http://imgur.com/EZNXcD3

    I currently have:

    Code:
    local f = CreateFrame("Frame")
    f:RegisterEvent("UPDATE_TRADESKILL_RECAST")
    
    local function My_Function()
    	-- get clicked item info (how ?)
    end
    
    f:SetScript('OnEvent', My_Function)

    By "clicked item", I mean the output item that is displayed on the right side of the window, when you click on a recipe in the left side. Thanks for any tips.
    Last edited by Eommus; 2017-05-23 at 04:13 PM.

  2. #2
    Quote Originally Posted by Eommus View Post
    How do you get the clicked item info using the UPDATE_TRADESKILL_RECAST event

    The UPDATE_TRADESKILL_RECAST event only seems to be for updating the repeat count when creating multiples of a tradeskill item, I have no idea why you would use that event for getting the "output item" information. Could you clarify a bit what you are trying to do?


    You can continue asking on WoWInterface for more information

  3. #3
    Quote Originally Posted by Ketho View Post
    Could you clarify a bit what you are trying to do?
    I am building a simple addon which will display item tooltip to the right of the Profession window, when I click on a recipe in the list. Something like the following:

    http://imgur.com/xY8t682

    When I click on Black Mageweave Headband from the list, the item's tooltip will be displayed as shown in the image above.

    The first step was to identify what event I need to start with for the "click on the recipe" action.

    I am new to lua and addon coding, so I am just trying to figure out how to do things, often times starting with not the best options, since I don't know what the best option is. I am checking other addons but since they are usually overly complicated for a beginner like me, it is hard to figure out how a simple thing is done by looking at their code.

  4. #4
    Quote Originally Posted by Eommus View Post
    I am building a simple addon which will display item tooltip to the right of the Profession window, when I click on a recipe in the list.

    If you specifically want to do something when clicking on a recipe (instead of e.g. on mouseover) this should work
    Blizzard_TradeSkillRecipeButton.xml#L201-L211
    Code:
    hooksecurefunc(TradeSkillFrame.RecipeList, "OnRecipeButtonClicked", function(self, ...)
    	print("OnRecipeButtonClicked", ...)
    end)

    It's a good practice to make your addon LoadOnDemand if it isn't already (http://addon.bool.no/)
    Code:
    ## Interface: 70200
    ## Title: MyFirstAddOn
    ## LoadOnDemand: 1
    ## LoadWith: Blizzard_TradeSkillUI

  5. #5
    @Ketho: Thank you for the LoadOnDemand tip and the other tip.

    I think I can fire my tooltip script with

    1) OnRecipeButtonClicked, as you showed above,

    and

    2) TRADE_SKILL_DATA_SOURCE_CHANGED, which fires when you open a profession window. Why need this? Because when you open a profession window, you see a recipe selected by default. I want that recipe's tooltip to be displayed too.

    Now, I need to figure out how to get the item info in these two cases.

    EDIT: I was able to get the recipe spell ID using the following:

    Code:
    hooksecurefunc(TradeSkillFrame.RecipeList, "OnRecipeButtonClicked", function(self, ...)
    	local recipeId = TradeSkillFrame.DetailsFrame.selectedRecipeID
    	print(recipeId)
    end)

    I was able to get the item ID using the following:

    Code:
    hooksecurefunc(TradeSkillFrame.RecipeList, "OnRecipeButtonClicked", function(self, ...)
    	local itemId = C_TradeSkillUI.GetRecipeItemLink(TradeSkillFrame.RecipeList.selectedRecipeID):match("item:(%d+):")
    	print(itemId)
    end)

    From the professions I checked so far, it works for tailoring, blacksmithing, mining but doesn't work for enchanting (most recipes), which displays spell instead of the item on the right section of the profession window. I can live with that.

    Now that I got the item info, my next step is to display the item tooltip to the right of the profession window.

    EDIT 2: Thanks for the tips. I was able to finish it just the way I wanted and also published it, in case others might need the same thing.

    https://mods.curse.com/addons/wow/26...n-item-tooltip
    Last edited by Eommus; 2017-05-25 at 04:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •