View Single Post
09-03-17, 02:30 PM   #3
coomacheek
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Sep 2017
Posts: 4
Thanks, but I wasn't able to get your code to work. For me arg1 was never equal to "Blizzard_TradeSkillUI" (arg1 kept showing up as other addon names). Once I corrected for that I was able to get the code to run, but the text wasn't always formatted at the bottom within the frame. I believe that was driven by the recipe (some have more text than others).

Here's the code I ended up using:

Code:
local details = TradeSkillFrame.DetailsFrame
local contents = details.Contents
local myStuff = details.Contents:CreateFontString(nil,"ARTWORK","GameFontNormal")
myStuff:SetSize(290,0)
myStuff:SetJustifyH("LEFT")


-- function that runs after a RefreshDisplay
local function update(recipeID)
    
  if not recipeID then
    return -- if no recipeID yet, leave; a refresh will happen with one
  end

  local lastWidget
  
  -- if NextRankText+SoureText is in details, attach myStuff to it
  if contents.SourceText:IsVisible() then
    lastWidget = contents.SourceText
  else -- otherwise attach to last item (likely a reagent) that anchors to TOPLEFT

	for _,widget in ipairs(details.activeContentWidgets) do
	  if widget:IsVisible() and widget:GetPoint()=="TOPLEFT" then
		lastWidget = widget
	  end
	end
  end
  
  local recipeLink = C_TradeSkillUI.GetRecipeItemLink(recipeID);
  
  myStuff:SetPoint("TOPLEFT",lastWidget,"BOTTOMLEFT",0,0)
  myStuff:SetText("My text would go here"))
end

hooksecurefunc(details,"RefreshDisplay",function(self)
	local recipeID = TradeSkillFrame.RecipeList:GetSelectedRecipeID()
	update(recipeID)
end)
  Reply With Quote